Исходник MultiPoints | Any version & base

Начинающий
Статус
Оффлайн
Регистрация
18 Авг 2023
Сообщения
376
Реакции[?]
2
Поинты[?]
1K

Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:

  • бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
  • маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
  • приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
  • обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.

Спасибо!

бебра:
public static Vec3d getAdaptivePoint(Entity entity) {
        Vec3d eyePos = mc.player.getEyePos();
        Vec3d playerPos = mc.player.getPos();

        Vec3d basePoint = getSpot(eyePos, entity);
        Vec3d multiPoint = getBestVisiblePoint2(eyePos, entity);

        boolean isBasePointVisible = isVisible(eyePos, basePoint);
        boolean isMultiPointVisible = isVisible(eyePos, multiPoint);

        double distToMultiPoint = multiPoint.squaredDistanceTo(playerPos);
        double distToBasePoint = basePoint.squaredDistanceTo(playerPos);

        if (isMultiPointVisible && isBasePointVisible) {
            return distToMultiPoint < distToBasePoint ? multiPoint : basePoint;
        } else if (isMultiPointVisible) {
            return multiPoint;
        } else if (isBasePointVisible) {
            return basePoint;
        } else {
            Vec3d entityCenter = entity.getBoundingBox().getCenter();
            boolean isMultiPointVisibleFromCenter = isVisible(entityCenter, multiPoint);
            boolean isBasePointVisibleFromCenter = isVisible(entityCenter, basePoint);

            if (isMultiPointVisibleFromCenter && !isBasePointVisibleFromCenter) {
                return multiPoint;
            } else if (!isMultiPointVisibleFromCenter && isBasePointVisibleFromCenter) {
                return basePoint;
            } else {
                return distToMultiPoint < distToBasePoint ? multiPoint : basePoint;
            }
        }
    }

    public static Vec3d getBestVisiblePoint(Vec3d pos, Entity entity, int p) {
        if (entity == null) return new Vec3d(0.0D, 0.0D, 0.0D);

        Vec3d closestPoint = null;
        double closestDistance = Double.MAX_VALUE;

        Box boundingBox = entity.getBoundingBox();
        List<Vec3d> points = new ArrayList<>();

        addCorners(boundingBox, points);

        // чем больше "p", тем больше точек, но меньше фпс

        for (double x : new double[]{boundingBox.minX, boundingBox.maxX}) {
            addVerticalPoints(boundingBox, points, x, p);
        }

        for (double z : new double[]{boundingBox.minZ, boundingBox.maxZ}) {
            addHorizontalPoints(boundingBox, points, z, p);
        }

        for (int i = 0; i <= p; i++) {
            double x = boundingBox.minX + (boundingBox.maxX - boundingBox.minX) * i / p;
            points.add(new Vec3d(x, boundingBox.minY, boundingBox.minZ));
            points.add(new Vec3d(x, boundingBox.minY, boundingBox.maxZ));
            points.add(new Vec3d(x, boundingBox.maxY, boundingBox.minZ));
            points.add(new Vec3d(x, boundingBox.maxY, boundingBox.maxZ));
        }

        points.add(new Vec3d((boundingBox.minX + boundingBox.maxX) / 2,
                (boundingBox.minY + boundingBox.maxY) / 2,
                (boundingBox.minZ + boundingBox.maxZ) / 2));

        for (Vec3d point : points) {
            if (isVisible(pos, point)) {
                double distance = pos.squaredDistanceTo(point);
                if (distance < closestDistance) {
                    closestDistance = distance;
                    closestPoint = point;
                }
            }
        }

        return closestPoint != null ? closestPoint : new Vec3d(0.0D, 0.0D, 0.0D);
    }

    public static final Vec3d[] PRECOMPUTED_POINTS = {
            new Vec3d(0.0, 0.0, 0.0),
            new Vec3d(0.0, 0.0, 1.0),
            new Vec3d(0.0, 1.0, 0.0),
            new Vec3d(0.0, 1.0, 1.0),
            new Vec3d(1.0, 0.0, 0.0),
            new Vec3d(1.0, 0.0, 1.0),
            new Vec3d(1.0, 1.0, 0.0),
            new Vec3d(1.0, 1.0, 1.0),
            new Vec3d(0.0, 0.0, 0.5),
            new Vec3d(0.0, 0.5, 0.0),
            new Vec3d(0.0, 0.5, 1.0),
            new Vec3d(0.0, 1.0, 0.5),
            new Vec3d(0.5, 0.0, 0.0),
            new Vec3d(0.5, 0.0, 1.0),
            new Vec3d(0.5, 1.0, 0.0),
            new Vec3d(0.5, 1.0, 1.0),
            new Vec3d(1.0, 0.0, 0.5),
            new Vec3d(1.0, 0.5, 0.0),
            new Vec3d(1.0, 0.5, 1.0),
            new Vec3d(1.0, 1.0, 0.5),
            new Vec3d(0.5, 0.5, 0.0),
            new Vec3d(0.5, 0.5, 1.0),
            new Vec3d(0.0, 0.5, 0.5),
            new Vec3d(1.0, 0.5, 0.5),
            new Vec3d(0.5, 0.0, 0.5),
            new Vec3d(0.5, 1.0, 0.5),
            new Vec3d(0.25, 0.25, 0.25),
            new Vec3d(0.25, 0.25, 0.75),
            new Vec3d(0.25, 0.75, 0.25),
            new Vec3d(0.25, 0.75, 0.75),
            new Vec3d(0.75, 0.25, 0.25),
            new Vec3d(0.75, 0.25, 0.75),
            new Vec3d(0.75, 0.75, 0.25),
            new Vec3d(0.75, 0.75, 0.75),
            new Vec3d(0.0, 0.25, 0.0),
            new Vec3d(0.0, 0.25, 1.0),
            new Vec3d(0.0, 0.75, 0.0),
            new Vec3d(0.0, 0.75, 1.0),
            new Vec3d(1.0, 0.25, 0.0),
            new Vec3d(1.0, 0.25, 1.0),
            new Vec3d(1.0, 0.75, 0.0),
            new Vec3d(1.0, 0.75, 1.0),
            new Vec3d(0.25, 0.0, 0.0),
            new Vec3d(0.25, 0.0, 1.0),
            new Vec3d(0.25, 1.0, 0.0),
            new Vec3d(0.25, 1.0, 1.0),
            new Vec3d(0.75, 0.0, 0.0),
            new Vec3d(0.75, 0.0, 1.0),
            new Vec3d(0.75, 1.0, 0.0),
            new Vec3d(0.75, 1.0, 1.0),
            new Vec3d(0.125, 0.125, 0.125),
            new Vec3d(0.125, 0.125, 0.875),
            new Vec3d(0.125, 0.875, 0.125),
            new Vec3d(0.125, 0.875, 0.875),
            new Vec3d(0.875, 0.125, 0.125),
            new Vec3d(0.875, 0.125, 0.875),
            new Vec3d(0.875, 0.875, 0.125),
            new Vec3d(0.875, 0.875, 0.875),
            new Vec3d(0.333, 0.333, 0.333),
            new Vec3d(0.333, 0.333, 0.666),
            new Vec3d(0.333, 0.666, 0.333),
            new Vec3d(0.333, 0.666, 0.666),
            new Vec3d(0.666, 0.333, 0.333),
            new Vec3d(0.666, 0.333, 0.666),
            new Vec3d(0.666, 0.666, 0.333),
            new Vec3d(0.666, 0.666, 0.666),
            new Vec3d(0.0, 0.333, 0.0),
            new Vec3d(0.0, 0.333, 1.0),
            new Vec3d(0.0, 0.666, 0.0),
            new Vec3d(0.0, 0.666, 1.0),
            new Vec3d(1.0, 0.333, 0.0),
            new Vec3d(1.0, 0.333, 1.0),
            new Vec3d(1.0, 0.666, 0.0),
            new Vec3d(1.0, 0.666, 1.0),
            new Vec3d(0.333, 0.0, 0.0),
            new Vec3d(0.333, 0.0, 1.0),
            new Vec3d(0.333, 1.0, 0.0),
            new Vec3d(0.333, 1.0, 1.0),
            new Vec3d(0.666, 0.0, 0.0),
            new Vec3d(0.666, 0.0, 1.0),
            new Vec3d(0.666, 1.0, 0.0),
            new Vec3d(0.666, 1.0, 1.0),
            new Vec3d(0.0, 0.0, 0.25),
            new Vec3d(0.0, 0.0, 0.75),
            new Vec3d(1.0, 0.0, 0.25),
            new Vec3d(1.0, 0.0, 0.75),
            new Vec3d(0.0, 1.0, 0.25),
            new Vec3d(0.0, 1.0, 0.75),
            new Vec3d(1.0, 1.0, 0.25),
            new Vec3d(1.0, 1.0, 0.75),
            new Vec3d(0.5, 0.5, 0.25),
            new Vec3d(0.5, 0.5, 0.75),
            new Vec3d(0.25, 0.25, 0.0),
            new Vec3d(0.25, 0.25, 1.0),
            new Vec3d(0.75, 0.75, 0.0),
            new Vec3d(0.75, 0.75, 1.0),
            new Vec3d(0.5, 0.25, 0.0),
            new Vec3d(0.5, 0.25, 1.0),
            new Vec3d(0.5, 0.75, 0.0),
            new Vec3d(0.5, 0.75, 1.0),
            new Vec3d(0.25, 0.5, 0.0),
            new Vec3d(0.25, 0.5, 1.0),
            new Vec3d(0.75, 0.5, 0.0),
            new Vec3d(0.75, 0.5, 1.0),
            new Vec3d(0.0, 0.5, 0.25),
            new Vec3d(0.0, 0.5, 0.75),
            new Vec3d(1.0, 0.5, 0.25),
            new Vec3d(1.0, 0.5, 0.75),
            new Vec3d(0.25, 0.0, 0.25),
            new Vec3d(0.25, 0.0, 0.75),
            new Vec3d(0.75, 0.0, 0.25),
            new Vec3d(0.75, 0.0, 0.75),
            new Vec3d(0.25, 1.0, 0.25),
            new Vec3d(0.25, 1.0, 0.75),
            new Vec3d(0.75, 1.0, 0.25),
            new Vec3d(0.75, 1.0, 0.75),
            new Vec3d(0.5, 0.25, 0.25),
            new Vec3d(0.5, 0.25, 0.75),
            new Vec3d(0.5, 0.75, 0.25),
            new Vec3d(0.5, 0.75, 0.75),
    };

    public static Vec3d getBestVisiblePoint2(Vec3d pos, Entity entity) {
        if (entity == null) {
            return null;
        }

        Box entityBox = entity.getBoundingBox();
        double closestDistance = Double.MAX_VALUE;
        Vec3d closestPoint = null;

        for (Vec3d point : PRECOMPUTED_POINTS) {
            Vec3d transformedPoint = new Vec3d(
                    entityBox.minX + point.x * (entityBox.maxX - entityBox.minX),
                    entityBox.minY + point.y * (entityBox.maxY - entityBox.minY),
                    entityBox.minZ + point.z * (entityBox.maxZ - entityBox.minZ)
            );

            if (isVisible(pos, transformedPoint)) {
                double distance = pos.squaredDistanceTo(transformedPoint);
                if (distance < closestDistance) {
                    closestDistance = distance;
                    closestPoint = transformedPoint;
                }
            }
        }

        if (closestPoint == null) {
            return getSpot(mc.player.getEyePos(), entity);
        }

        return closestPoint;
    }

    private static void addCorners(Box boundingBox, List<Vec3d> points) {
        points.add(new Vec3d(boundingBox.minX, boundingBox.minY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.minY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.maxY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.minY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ));
    }

    private static void addVerticalPoints(Box boundingBox, List<Vec3d> points, double x, int divisions) {
        for (int i = 0; i <= divisions; i++) {
            double y = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * i / divisions;
            points.add(new Vec3d(x, y, boundingBox.minZ));
            points.add(new Vec3d(x, y, boundingBox.maxZ));
        }
    }

    private static void addHorizontalPoints(Box boundingBox, List<Vec3d> points, double z, int divisions) {
        for (int i = 0; i <= divisions; i++) {
            double y = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * i / divisions;
            points.add(new Vec3d(boundingBox.minX, y, z));
            points.add(new Vec3d(boundingBox.maxX, y, z));
        }
    }

    public static boolean isVisible(Vec3d from, Vec3d to) {
        HitResult hitResult = mc.world.raycast(new RaycastContext(from, to, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, mc.player));
        return hitResult == null || hitResult.getType() == HitResult.Type.MISS;
    }
Пожалуйста, авторизуйтесь для просмотра ссылки.
 
Начинающий
Статус
Оффлайн
Регистрация
3 Май 2023
Сообщения
557
Реакции[?]
3
Поинты[?]
2K
бебра:
public static Vec3d getAdaptivePoint(Entity entity) {
        Vec3d eyePos = mc.player.getEyePos();
        Vec3d playerPos = mc.player.getPos();

        Vec3d basePoint = getSpot(eyePos, entity);
        Vec3d multiPoint = getBestVisiblePoint2(eyePos, entity);

        boolean isBasePointVisible = isVisible(eyePos, basePoint);
        boolean isMultiPointVisible = isVisible(eyePos, multiPoint);

        double distToMultiPoint = multiPoint.squaredDistanceTo(playerPos);
        double distToBasePoint = basePoint.squaredDistanceTo(playerPos);

        if (isMultiPointVisible && isBasePointVisible) {
            return distToMultiPoint < distToBasePoint ? multiPoint : basePoint;
        } else if (isMultiPointVisible) {
            return multiPoint;
        } else if (isBasePointVisible) {
            return basePoint;
        } else {
            Vec3d entityCenter = entity.getBoundingBox().getCenter();
            boolean isMultiPointVisibleFromCenter = isVisible(entityCenter, multiPoint);
            boolean isBasePointVisibleFromCenter = isVisible(entityCenter, basePoint);

            if (isMultiPointVisibleFromCenter && !isBasePointVisibleFromCenter) {
                return multiPoint;
            } else if (!isMultiPointVisibleFromCenter && isBasePointVisibleFromCenter) {
                return basePoint;
            } else {
                return distToMultiPoint < distToBasePoint ? multiPoint : basePoint;
            }
        }
    }

    public static Vec3d getBestVisiblePoint(Vec3d pos, Entity entity, int p) {
        if (entity == null) return new Vec3d(0.0D, 0.0D, 0.0D);

        Vec3d closestPoint = null;
        double closestDistance = Double.MAX_VALUE;

        Box boundingBox = entity.getBoundingBox();
        List<Vec3d> points = new ArrayList<>();

        addCorners(boundingBox, points);

        // чем больше "p", тем больше точек, но меньше фпс

        for (double x : new double[]{boundingBox.minX, boundingBox.maxX}) {
            addVerticalPoints(boundingBox, points, x, p);
        }

        for (double z : new double[]{boundingBox.minZ, boundingBox.maxZ}) {
            addHorizontalPoints(boundingBox, points, z, p);
        }

        for (int i = 0; i <= p; i++) {
            double x = boundingBox.minX + (boundingBox.maxX - boundingBox.minX) * i / p;
            points.add(new Vec3d(x, boundingBox.minY, boundingBox.minZ));
            points.add(new Vec3d(x, boundingBox.minY, boundingBox.maxZ));
            points.add(new Vec3d(x, boundingBox.maxY, boundingBox.minZ));
            points.add(new Vec3d(x, boundingBox.maxY, boundingBox.maxZ));
        }

        points.add(new Vec3d((boundingBox.minX + boundingBox.maxX) / 2,
                (boundingBox.minY + boundingBox.maxY) / 2,
                (boundingBox.minZ + boundingBox.maxZ) / 2));

        for (Vec3d point : points) {
            if (isVisible(pos, point)) {
                double distance = pos.squaredDistanceTo(point);
                if (distance < closestDistance) {
                    closestDistance = distance;
                    closestPoint = point;
                }
            }
        }

        return closestPoint != null ? closestPoint : new Vec3d(0.0D, 0.0D, 0.0D);
    }

    public static final Vec3d[] PRECOMPUTED_POINTS = {
            new Vec3d(0.0, 0.0, 0.0),
            new Vec3d(0.0, 0.0, 1.0),
            new Vec3d(0.0, 1.0, 0.0),
            new Vec3d(0.0, 1.0, 1.0),
            new Vec3d(1.0, 0.0, 0.0),
            new Vec3d(1.0, 0.0, 1.0),
            new Vec3d(1.0, 1.0, 0.0),
            new Vec3d(1.0, 1.0, 1.0),
            new Vec3d(0.0, 0.0, 0.5),
            new Vec3d(0.0, 0.5, 0.0),
            new Vec3d(0.0, 0.5, 1.0),
            new Vec3d(0.0, 1.0, 0.5),
            new Vec3d(0.5, 0.0, 0.0),
            new Vec3d(0.5, 0.0, 1.0),
            new Vec3d(0.5, 1.0, 0.0),
            new Vec3d(0.5, 1.0, 1.0),
            new Vec3d(1.0, 0.0, 0.5),
            new Vec3d(1.0, 0.5, 0.0),
            new Vec3d(1.0, 0.5, 1.0),
            new Vec3d(1.0, 1.0, 0.5),
            new Vec3d(0.5, 0.5, 0.0),
            new Vec3d(0.5, 0.5, 1.0),
            new Vec3d(0.0, 0.5, 0.5),
            new Vec3d(1.0, 0.5, 0.5),
            new Vec3d(0.5, 0.0, 0.5),
            new Vec3d(0.5, 1.0, 0.5),
            new Vec3d(0.25, 0.25, 0.25),
            new Vec3d(0.25, 0.25, 0.75),
            new Vec3d(0.25, 0.75, 0.25),
            new Vec3d(0.25, 0.75, 0.75),
            new Vec3d(0.75, 0.25, 0.25),
            new Vec3d(0.75, 0.25, 0.75),
            new Vec3d(0.75, 0.75, 0.25),
            new Vec3d(0.75, 0.75, 0.75),
            new Vec3d(0.0, 0.25, 0.0),
            new Vec3d(0.0, 0.25, 1.0),
            new Vec3d(0.0, 0.75, 0.0),
            new Vec3d(0.0, 0.75, 1.0),
            new Vec3d(1.0, 0.25, 0.0),
            new Vec3d(1.0, 0.25, 1.0),
            new Vec3d(1.0, 0.75, 0.0),
            new Vec3d(1.0, 0.75, 1.0),
            new Vec3d(0.25, 0.0, 0.0),
            new Vec3d(0.25, 0.0, 1.0),
            new Vec3d(0.25, 1.0, 0.0),
            new Vec3d(0.25, 1.0, 1.0),
            new Vec3d(0.75, 0.0, 0.0),
            new Vec3d(0.75, 0.0, 1.0),
            new Vec3d(0.75, 1.0, 0.0),
            new Vec3d(0.75, 1.0, 1.0),
            new Vec3d(0.125, 0.125, 0.125),
            new Vec3d(0.125, 0.125, 0.875),
            new Vec3d(0.125, 0.875, 0.125),
            new Vec3d(0.125, 0.875, 0.875),
            new Vec3d(0.875, 0.125, 0.125),
            new Vec3d(0.875, 0.125, 0.875),
            new Vec3d(0.875, 0.875, 0.125),
            new Vec3d(0.875, 0.875, 0.875),
            new Vec3d(0.333, 0.333, 0.333),
            new Vec3d(0.333, 0.333, 0.666),
            new Vec3d(0.333, 0.666, 0.333),
            new Vec3d(0.333, 0.666, 0.666),
            new Vec3d(0.666, 0.333, 0.333),
            new Vec3d(0.666, 0.333, 0.666),
            new Vec3d(0.666, 0.666, 0.333),
            new Vec3d(0.666, 0.666, 0.666),
            new Vec3d(0.0, 0.333, 0.0),
            new Vec3d(0.0, 0.333, 1.0),
            new Vec3d(0.0, 0.666, 0.0),
            new Vec3d(0.0, 0.666, 1.0),
            new Vec3d(1.0, 0.333, 0.0),
            new Vec3d(1.0, 0.333, 1.0),
            new Vec3d(1.0, 0.666, 0.0),
            new Vec3d(1.0, 0.666, 1.0),
            new Vec3d(0.333, 0.0, 0.0),
            new Vec3d(0.333, 0.0, 1.0),
            new Vec3d(0.333, 1.0, 0.0),
            new Vec3d(0.333, 1.0, 1.0),
            new Vec3d(0.666, 0.0, 0.0),
            new Vec3d(0.666, 0.0, 1.0),
            new Vec3d(0.666, 1.0, 0.0),
            new Vec3d(0.666, 1.0, 1.0),
            new Vec3d(0.0, 0.0, 0.25),
            new Vec3d(0.0, 0.0, 0.75),
            new Vec3d(1.0, 0.0, 0.25),
            new Vec3d(1.0, 0.0, 0.75),
            new Vec3d(0.0, 1.0, 0.25),
            new Vec3d(0.0, 1.0, 0.75),
            new Vec3d(1.0, 1.0, 0.25),
            new Vec3d(1.0, 1.0, 0.75),
            new Vec3d(0.5, 0.5, 0.25),
            new Vec3d(0.5, 0.5, 0.75),
            new Vec3d(0.25, 0.25, 0.0),
            new Vec3d(0.25, 0.25, 1.0),
            new Vec3d(0.75, 0.75, 0.0),
            new Vec3d(0.75, 0.75, 1.0),
            new Vec3d(0.5, 0.25, 0.0),
            new Vec3d(0.5, 0.25, 1.0),
            new Vec3d(0.5, 0.75, 0.0),
            new Vec3d(0.5, 0.75, 1.0),
            new Vec3d(0.25, 0.5, 0.0),
            new Vec3d(0.25, 0.5, 1.0),
            new Vec3d(0.75, 0.5, 0.0),
            new Vec3d(0.75, 0.5, 1.0),
            new Vec3d(0.0, 0.5, 0.25),
            new Vec3d(0.0, 0.5, 0.75),
            new Vec3d(1.0, 0.5, 0.25),
            new Vec3d(1.0, 0.5, 0.75),
            new Vec3d(0.25, 0.0, 0.25),
            new Vec3d(0.25, 0.0, 0.75),
            new Vec3d(0.75, 0.0, 0.25),
            new Vec3d(0.75, 0.0, 0.75),
            new Vec3d(0.25, 1.0, 0.25),
            new Vec3d(0.25, 1.0, 0.75),
            new Vec3d(0.75, 1.0, 0.25),
            new Vec3d(0.75, 1.0, 0.75),
            new Vec3d(0.5, 0.25, 0.25),
            new Vec3d(0.5, 0.25, 0.75),
            new Vec3d(0.5, 0.75, 0.25),
            new Vec3d(0.5, 0.75, 0.75),
    };

    public static Vec3d getBestVisiblePoint2(Vec3d pos, Entity entity) {
        if (entity == null) {
            return null;
        }

        Box entityBox = entity.getBoundingBox();
        double closestDistance = Double.MAX_VALUE;
        Vec3d closestPoint = null;

        for (Vec3d point : PRECOMPUTED_POINTS) {
            Vec3d transformedPoint = new Vec3d(
                    entityBox.minX + point.x * (entityBox.maxX - entityBox.minX),
                    entityBox.minY + point.y * (entityBox.maxY - entityBox.minY),
                    entityBox.minZ + point.z * (entityBox.maxZ - entityBox.minZ)
            );

            if (isVisible(pos, transformedPoint)) {
                double distance = pos.squaredDistanceTo(transformedPoint);
                if (distance < closestDistance) {
                    closestDistance = distance;
                    closestPoint = transformedPoint;
                }
            }
        }

        if (closestPoint == null) {
            return getSpot(mc.player.getEyePos(), entity);
        }

        return closestPoint;
    }

    private static void addCorners(Box boundingBox, List<Vec3d> points) {
        points.add(new Vec3d(boundingBox.minX, boundingBox.minY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.minY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.maxY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.minY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ));
    }

    private static void addVerticalPoints(Box boundingBox, List<Vec3d> points, double x, int divisions) {
        for (int i = 0; i <= divisions; i++) {
            double y = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * i / divisions;
            points.add(new Vec3d(x, y, boundingBox.minZ));
            points.add(new Vec3d(x, y, boundingBox.maxZ));
        }
    }

    private static void addHorizontalPoints(Box boundingBox, List<Vec3d> points, double z, int divisions) {
        for (int i = 0; i <= divisions; i++) {
            double y = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * i / divisions;
            points.add(new Vec3d(boundingBox.minX, y, z));
            points.add(new Vec3d(boundingBox.maxX, y, z));
        }
    }

    public static boolean isVisible(Vec3d from, Vec3d to) {
        HitResult hitResult = mc.world.raycast(new RaycastContext(from, to, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, mc.player));
        return hitResult == null || hitResult.getType() == HitResult.Type.MISS;
    }
Пожалуйста, авторизуйтесь для просмотра ссылки.
зачем вообще multipoints и за что оно отвечает ?
 
Начинающий
Статус
Оффлайн
Регистрация
18 Авг 2023
Сообщения
376
Реакции[?]
2
Поинты[?]
1K
Начинающий
Статус
Оффлайн
Регистрация
27 Окт 2021
Сообщения
38
Реакции[?]
0
Поинты[?]
0
бебра:
public static Vec3d getAdaptivePoint(Entity entity) {
        Vec3d eyePos = mc.player.getEyePos();
        Vec3d playerPos = mc.player.getPos();

        Vec3d basePoint = getSpot(eyePos, entity);
        Vec3d multiPoint = getBestVisiblePoint2(eyePos, entity);

        boolean isBasePointVisible = isVisible(eyePos, basePoint);
        boolean isMultiPointVisible = isVisible(eyePos, multiPoint);

        double distToMultiPoint = multiPoint.squaredDistanceTo(playerPos);
        double distToBasePoint = basePoint.squaredDistanceTo(playerPos);

        if (isMultiPointVisible && isBasePointVisible) {
            return distToMultiPoint < distToBasePoint ? multiPoint : basePoint;
        } else if (isMultiPointVisible) {
            return multiPoint;
        } else if (isBasePointVisible) {
            return basePoint;
        } else {
            Vec3d entityCenter = entity.getBoundingBox().getCenter();
            boolean isMultiPointVisibleFromCenter = isVisible(entityCenter, multiPoint);
            boolean isBasePointVisibleFromCenter = isVisible(entityCenter, basePoint);

            if (isMultiPointVisibleFromCenter && !isBasePointVisibleFromCenter) {
                return multiPoint;
            } else if (!isMultiPointVisibleFromCenter && isBasePointVisibleFromCenter) {
                return basePoint;
            } else {
                return distToMultiPoint < distToBasePoint ? multiPoint : basePoint;
            }
        }
    }

    public static Vec3d getBestVisiblePoint(Vec3d pos, Entity entity, int p) {
        if (entity == null) return new Vec3d(0.0D, 0.0D, 0.0D);

        Vec3d closestPoint = null;
        double closestDistance = Double.MAX_VALUE;

        Box boundingBox = entity.getBoundingBox();
        List<Vec3d> points = new ArrayList<>();

        addCorners(boundingBox, points);

        // чем больше "p", тем больше точек, но меньше фпс

        for (double x : new double[]{boundingBox.minX, boundingBox.maxX}) {
            addVerticalPoints(boundingBox, points, x, p);
        }

        for (double z : new double[]{boundingBox.minZ, boundingBox.maxZ}) {
            addHorizontalPoints(boundingBox, points, z, p);
        }

        for (int i = 0; i <= p; i++) {
            double x = boundingBox.minX + (boundingBox.maxX - boundingBox.minX) * i / p;
            points.add(new Vec3d(x, boundingBox.minY, boundingBox.minZ));
            points.add(new Vec3d(x, boundingBox.minY, boundingBox.maxZ));
            points.add(new Vec3d(x, boundingBox.maxY, boundingBox.minZ));
            points.add(new Vec3d(x, boundingBox.maxY, boundingBox.maxZ));
        }

        points.add(new Vec3d((boundingBox.minX + boundingBox.maxX) / 2,
                (boundingBox.minY + boundingBox.maxY) / 2,
                (boundingBox.minZ + boundingBox.maxZ) / 2));

        for (Vec3d point : points) {
            if (isVisible(pos, point)) {
                double distance = pos.squaredDistanceTo(point);
                if (distance < closestDistance) {
                    closestDistance = distance;
                    closestPoint = point;
                }
            }
        }

        return closestPoint != null ? closestPoint : new Vec3d(0.0D, 0.0D, 0.0D);
    }

    public static final Vec3d[] PRECOMPUTED_POINTS = {
            new Vec3d(0.0, 0.0, 0.0),
            new Vec3d(0.0, 0.0, 1.0),
            new Vec3d(0.0, 1.0, 0.0),
            new Vec3d(0.0, 1.0, 1.0),
            new Vec3d(1.0, 0.0, 0.0),
            new Vec3d(1.0, 0.0, 1.0),
            new Vec3d(1.0, 1.0, 0.0),
            new Vec3d(1.0, 1.0, 1.0),
            new Vec3d(0.0, 0.0, 0.5),
            new Vec3d(0.0, 0.5, 0.0),
            new Vec3d(0.0, 0.5, 1.0),
            new Vec3d(0.0, 1.0, 0.5),
            new Vec3d(0.5, 0.0, 0.0),
            new Vec3d(0.5, 0.0, 1.0),
            new Vec3d(0.5, 1.0, 0.0),
            new Vec3d(0.5, 1.0, 1.0),
            new Vec3d(1.0, 0.0, 0.5),
            new Vec3d(1.0, 0.5, 0.0),
            new Vec3d(1.0, 0.5, 1.0),
            new Vec3d(1.0, 1.0, 0.5),
            new Vec3d(0.5, 0.5, 0.0),
            new Vec3d(0.5, 0.5, 1.0),
            new Vec3d(0.0, 0.5, 0.5),
            new Vec3d(1.0, 0.5, 0.5),
            new Vec3d(0.5, 0.0, 0.5),
            new Vec3d(0.5, 1.0, 0.5),
            new Vec3d(0.25, 0.25, 0.25),
            new Vec3d(0.25, 0.25, 0.75),
            new Vec3d(0.25, 0.75, 0.25),
            new Vec3d(0.25, 0.75, 0.75),
            new Vec3d(0.75, 0.25, 0.25),
            new Vec3d(0.75, 0.25, 0.75),
            new Vec3d(0.75, 0.75, 0.25),
            new Vec3d(0.75, 0.75, 0.75),
            new Vec3d(0.0, 0.25, 0.0),
            new Vec3d(0.0, 0.25, 1.0),
            new Vec3d(0.0, 0.75, 0.0),
            new Vec3d(0.0, 0.75, 1.0),
            new Vec3d(1.0, 0.25, 0.0),
            new Vec3d(1.0, 0.25, 1.0),
            new Vec3d(1.0, 0.75, 0.0),
            new Vec3d(1.0, 0.75, 1.0),
            new Vec3d(0.25, 0.0, 0.0),
            new Vec3d(0.25, 0.0, 1.0),
            new Vec3d(0.25, 1.0, 0.0),
            new Vec3d(0.25, 1.0, 1.0),
            new Vec3d(0.75, 0.0, 0.0),
            new Vec3d(0.75, 0.0, 1.0),
            new Vec3d(0.75, 1.0, 0.0),
            new Vec3d(0.75, 1.0, 1.0),
            new Vec3d(0.125, 0.125, 0.125),
            new Vec3d(0.125, 0.125, 0.875),
            new Vec3d(0.125, 0.875, 0.125),
            new Vec3d(0.125, 0.875, 0.875),
            new Vec3d(0.875, 0.125, 0.125),
            new Vec3d(0.875, 0.125, 0.875),
            new Vec3d(0.875, 0.875, 0.125),
            new Vec3d(0.875, 0.875, 0.875),
            new Vec3d(0.333, 0.333, 0.333),
            new Vec3d(0.333, 0.333, 0.666),
            new Vec3d(0.333, 0.666, 0.333),
            new Vec3d(0.333, 0.666, 0.666),
            new Vec3d(0.666, 0.333, 0.333),
            new Vec3d(0.666, 0.333, 0.666),
            new Vec3d(0.666, 0.666, 0.333),
            new Vec3d(0.666, 0.666, 0.666),
            new Vec3d(0.0, 0.333, 0.0),
            new Vec3d(0.0, 0.333, 1.0),
            new Vec3d(0.0, 0.666, 0.0),
            new Vec3d(0.0, 0.666, 1.0),
            new Vec3d(1.0, 0.333, 0.0),
            new Vec3d(1.0, 0.333, 1.0),
            new Vec3d(1.0, 0.666, 0.0),
            new Vec3d(1.0, 0.666, 1.0),
            new Vec3d(0.333, 0.0, 0.0),
            new Vec3d(0.333, 0.0, 1.0),
            new Vec3d(0.333, 1.0, 0.0),
            new Vec3d(0.333, 1.0, 1.0),
            new Vec3d(0.666, 0.0, 0.0),
            new Vec3d(0.666, 0.0, 1.0),
            new Vec3d(0.666, 1.0, 0.0),
            new Vec3d(0.666, 1.0, 1.0),
            new Vec3d(0.0, 0.0, 0.25),
            new Vec3d(0.0, 0.0, 0.75),
            new Vec3d(1.0, 0.0, 0.25),
            new Vec3d(1.0, 0.0, 0.75),
            new Vec3d(0.0, 1.0, 0.25),
            new Vec3d(0.0, 1.0, 0.75),
            new Vec3d(1.0, 1.0, 0.25),
            new Vec3d(1.0, 1.0, 0.75),
            new Vec3d(0.5, 0.5, 0.25),
            new Vec3d(0.5, 0.5, 0.75),
            new Vec3d(0.25, 0.25, 0.0),
            new Vec3d(0.25, 0.25, 1.0),
            new Vec3d(0.75, 0.75, 0.0),
            new Vec3d(0.75, 0.75, 1.0),
            new Vec3d(0.5, 0.25, 0.0),
            new Vec3d(0.5, 0.25, 1.0),
            new Vec3d(0.5, 0.75, 0.0),
            new Vec3d(0.5, 0.75, 1.0),
            new Vec3d(0.25, 0.5, 0.0),
            new Vec3d(0.25, 0.5, 1.0),
            new Vec3d(0.75, 0.5, 0.0),
            new Vec3d(0.75, 0.5, 1.0),
            new Vec3d(0.0, 0.5, 0.25),
            new Vec3d(0.0, 0.5, 0.75),
            new Vec3d(1.0, 0.5, 0.25),
            new Vec3d(1.0, 0.5, 0.75),
            new Vec3d(0.25, 0.0, 0.25),
            new Vec3d(0.25, 0.0, 0.75),
            new Vec3d(0.75, 0.0, 0.25),
            new Vec3d(0.75, 0.0, 0.75),
            new Vec3d(0.25, 1.0, 0.25),
            new Vec3d(0.25, 1.0, 0.75),
            new Vec3d(0.75, 1.0, 0.25),
            new Vec3d(0.75, 1.0, 0.75),
            new Vec3d(0.5, 0.25, 0.25),
            new Vec3d(0.5, 0.25, 0.75),
            new Vec3d(0.5, 0.75, 0.25),
            new Vec3d(0.5, 0.75, 0.75),
    };

    public static Vec3d getBestVisiblePoint2(Vec3d pos, Entity entity) {
        if (entity == null) {
            return null;
        }

        Box entityBox = entity.getBoundingBox();
        double closestDistance = Double.MAX_VALUE;
        Vec3d closestPoint = null;

        for (Vec3d point : PRECOMPUTED_POINTS) {
            Vec3d transformedPoint = new Vec3d(
                    entityBox.minX + point.x * (entityBox.maxX - entityBox.minX),
                    entityBox.minY + point.y * (entityBox.maxY - entityBox.minY),
                    entityBox.minZ + point.z * (entityBox.maxZ - entityBox.minZ)
            );

            if (isVisible(pos, transformedPoint)) {
                double distance = pos.squaredDistanceTo(transformedPoint);
                if (distance < closestDistance) {
                    closestDistance = distance;
                    closestPoint = transformedPoint;
                }
            }
        }

        if (closestPoint == null) {
            return getSpot(mc.player.getEyePos(), entity);
        }

        return closestPoint;
    }

    private static void addCorners(Box boundingBox, List<Vec3d> points) {
        points.add(new Vec3d(boundingBox.minX, boundingBox.minY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.minY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.maxY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.minY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ));
    }

    private static void addVerticalPoints(Box boundingBox, List<Vec3d> points, double x, int divisions) {
        for (int i = 0; i <= divisions; i++) {
            double y = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * i / divisions;
            points.add(new Vec3d(x, y, boundingBox.minZ));
            points.add(new Vec3d(x, y, boundingBox.maxZ));
        }
    }

    private static void addHorizontalPoints(Box boundingBox, List<Vec3d> points, double z, int divisions) {
        for (int i = 0; i <= divisions; i++) {
            double y = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * i / divisions;
            points.add(new Vec3d(boundingBox.minX, y, z));
            points.add(new Vec3d(boundingBox.maxX, y, z));
        }
    }

    public static boolean isVisible(Vec3d from, Vec3d to) {
        HitResult hitResult = mc.world.raycast(new RaycastContext(from, to, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, mc.player));
        return hitResult == null || hitResult.getType() == HitResult.Type.MISS;
    }
Пожалуйста, авторизуйтесь для просмотра ссылки.
Так их же можно в 2-3 воида написать
 
Начинающий
Статус
Оффлайн
Регистрация
18 Авг 2023
Сообщения
376
Реакции[?]
2
Поинты[?]
1K
Начинающий
Статус
Оффлайн
Регистрация
3 Май 2023
Сообщения
557
Реакции[?]
3
Поинты[?]
2K
бебра:
public static Vec3d getAdaptivePoint(Entity entity) {
        Vec3d eyePos = mc.player.getEyePos();
        Vec3d playerPos = mc.player.getPos();

        Vec3d basePoint = getSpot(eyePos, entity);
        Vec3d multiPoint = getBestVisiblePoint2(eyePos, entity);

        boolean isBasePointVisible = isVisible(eyePos, basePoint);
        boolean isMultiPointVisible = isVisible(eyePos, multiPoint);

        double distToMultiPoint = multiPoint.squaredDistanceTo(playerPos);
        double distToBasePoint = basePoint.squaredDistanceTo(playerPos);

        if (isMultiPointVisible && isBasePointVisible) {
            return distToMultiPoint < distToBasePoint ? multiPoint : basePoint;
        } else if (isMultiPointVisible) {
            return multiPoint;
        } else if (isBasePointVisible) {
            return basePoint;
        } else {
            Vec3d entityCenter = entity.getBoundingBox().getCenter();
            boolean isMultiPointVisibleFromCenter = isVisible(entityCenter, multiPoint);
            boolean isBasePointVisibleFromCenter = isVisible(entityCenter, basePoint);

            if (isMultiPointVisibleFromCenter && !isBasePointVisibleFromCenter) {
                return multiPoint;
            } else if (!isMultiPointVisibleFromCenter && isBasePointVisibleFromCenter) {
                return basePoint;
            } else {
                return distToMultiPoint < distToBasePoint ? multiPoint : basePoint;
            }
        }
    }

    public static Vec3d getBestVisiblePoint(Vec3d pos, Entity entity, int p) {
        if (entity == null) return new Vec3d(0.0D, 0.0D, 0.0D);

        Vec3d closestPoint = null;
        double closestDistance = Double.MAX_VALUE;

        Box boundingBox = entity.getBoundingBox();
        List<Vec3d> points = new ArrayList<>();

        addCorners(boundingBox, points);

        // чем больше "p", тем больше точек, но меньше фпс

        for (double x : new double[]{boundingBox.minX, boundingBox.maxX}) {
            addVerticalPoints(boundingBox, points, x, p);
        }

        for (double z : new double[]{boundingBox.minZ, boundingBox.maxZ}) {
            addHorizontalPoints(boundingBox, points, z, p);
        }

        for (int i = 0; i <= p; i++) {
            double x = boundingBox.minX + (boundingBox.maxX - boundingBox.minX) * i / p;
            points.add(new Vec3d(x, boundingBox.minY, boundingBox.minZ));
            points.add(new Vec3d(x, boundingBox.minY, boundingBox.maxZ));
            points.add(new Vec3d(x, boundingBox.maxY, boundingBox.minZ));
            points.add(new Vec3d(x, boundingBox.maxY, boundingBox.maxZ));
        }

        points.add(new Vec3d((boundingBox.minX + boundingBox.maxX) / 2,
                (boundingBox.minY + boundingBox.maxY) / 2,
                (boundingBox.minZ + boundingBox.maxZ) / 2));

        for (Vec3d point : points) {
            if (isVisible(pos, point)) {
                double distance = pos.squaredDistanceTo(point);
                if (distance < closestDistance) {
                    closestDistance = distance;
                    closestPoint = point;
                }
            }
        }

        return closestPoint != null ? closestPoint : new Vec3d(0.0D, 0.0D, 0.0D);
    }

    public static final Vec3d[] PRECOMPUTED_POINTS = {
            new Vec3d(0.0, 0.0, 0.0),
            new Vec3d(0.0, 0.0, 1.0),
            new Vec3d(0.0, 1.0, 0.0),
            new Vec3d(0.0, 1.0, 1.0),
            new Vec3d(1.0, 0.0, 0.0),
            new Vec3d(1.0, 0.0, 1.0),
            new Vec3d(1.0, 1.0, 0.0),
            new Vec3d(1.0, 1.0, 1.0),
            new Vec3d(0.0, 0.0, 0.5),
            new Vec3d(0.0, 0.5, 0.0),
            new Vec3d(0.0, 0.5, 1.0),
            new Vec3d(0.0, 1.0, 0.5),
            new Vec3d(0.5, 0.0, 0.0),
            new Vec3d(0.5, 0.0, 1.0),
            new Vec3d(0.5, 1.0, 0.0),
            new Vec3d(0.5, 1.0, 1.0),
            new Vec3d(1.0, 0.0, 0.5),
            new Vec3d(1.0, 0.5, 0.0),
            new Vec3d(1.0, 0.5, 1.0),
            new Vec3d(1.0, 1.0, 0.5),
            new Vec3d(0.5, 0.5, 0.0),
            new Vec3d(0.5, 0.5, 1.0),
            new Vec3d(0.0, 0.5, 0.5),
            new Vec3d(1.0, 0.5, 0.5),
            new Vec3d(0.5, 0.0, 0.5),
            new Vec3d(0.5, 1.0, 0.5),
            new Vec3d(0.25, 0.25, 0.25),
            new Vec3d(0.25, 0.25, 0.75),
            new Vec3d(0.25, 0.75, 0.25),
            new Vec3d(0.25, 0.75, 0.75),
            new Vec3d(0.75, 0.25, 0.25),
            new Vec3d(0.75, 0.25, 0.75),
            new Vec3d(0.75, 0.75, 0.25),
            new Vec3d(0.75, 0.75, 0.75),
            new Vec3d(0.0, 0.25, 0.0),
            new Vec3d(0.0, 0.25, 1.0),
            new Vec3d(0.0, 0.75, 0.0),
            new Vec3d(0.0, 0.75, 1.0),
            new Vec3d(1.0, 0.25, 0.0),
            new Vec3d(1.0, 0.25, 1.0),
            new Vec3d(1.0, 0.75, 0.0),
            new Vec3d(1.0, 0.75, 1.0),
            new Vec3d(0.25, 0.0, 0.0),
            new Vec3d(0.25, 0.0, 1.0),
            new Vec3d(0.25, 1.0, 0.0),
            new Vec3d(0.25, 1.0, 1.0),
            new Vec3d(0.75, 0.0, 0.0),
            new Vec3d(0.75, 0.0, 1.0),
            new Vec3d(0.75, 1.0, 0.0),
            new Vec3d(0.75, 1.0, 1.0),
            new Vec3d(0.125, 0.125, 0.125),
            new Vec3d(0.125, 0.125, 0.875),
            new Vec3d(0.125, 0.875, 0.125),
            new Vec3d(0.125, 0.875, 0.875),
            new Vec3d(0.875, 0.125, 0.125),
            new Vec3d(0.875, 0.125, 0.875),
            new Vec3d(0.875, 0.875, 0.125),
            new Vec3d(0.875, 0.875, 0.875),
            new Vec3d(0.333, 0.333, 0.333),
            new Vec3d(0.333, 0.333, 0.666),
            new Vec3d(0.333, 0.666, 0.333),
            new Vec3d(0.333, 0.666, 0.666),
            new Vec3d(0.666, 0.333, 0.333),
            new Vec3d(0.666, 0.333, 0.666),
            new Vec3d(0.666, 0.666, 0.333),
            new Vec3d(0.666, 0.666, 0.666),
            new Vec3d(0.0, 0.333, 0.0),
            new Vec3d(0.0, 0.333, 1.0),
            new Vec3d(0.0, 0.666, 0.0),
            new Vec3d(0.0, 0.666, 1.0),
            new Vec3d(1.0, 0.333, 0.0),
            new Vec3d(1.0, 0.333, 1.0),
            new Vec3d(1.0, 0.666, 0.0),
            new Vec3d(1.0, 0.666, 1.0),
            new Vec3d(0.333, 0.0, 0.0),
            new Vec3d(0.333, 0.0, 1.0),
            new Vec3d(0.333, 1.0, 0.0),
            new Vec3d(0.333, 1.0, 1.0),
            new Vec3d(0.666, 0.0, 0.0),
            new Vec3d(0.666, 0.0, 1.0),
            new Vec3d(0.666, 1.0, 0.0),
            new Vec3d(0.666, 1.0, 1.0),
            new Vec3d(0.0, 0.0, 0.25),
            new Vec3d(0.0, 0.0, 0.75),
            new Vec3d(1.0, 0.0, 0.25),
            new Vec3d(1.0, 0.0, 0.75),
            new Vec3d(0.0, 1.0, 0.25),
            new Vec3d(0.0, 1.0, 0.75),
            new Vec3d(1.0, 1.0, 0.25),
            new Vec3d(1.0, 1.0, 0.75),
            new Vec3d(0.5, 0.5, 0.25),
            new Vec3d(0.5, 0.5, 0.75),
            new Vec3d(0.25, 0.25, 0.0),
            new Vec3d(0.25, 0.25, 1.0),
            new Vec3d(0.75, 0.75, 0.0),
            new Vec3d(0.75, 0.75, 1.0),
            new Vec3d(0.5, 0.25, 0.0),
            new Vec3d(0.5, 0.25, 1.0),
            new Vec3d(0.5, 0.75, 0.0),
            new Vec3d(0.5, 0.75, 1.0),
            new Vec3d(0.25, 0.5, 0.0),
            new Vec3d(0.25, 0.5, 1.0),
            new Vec3d(0.75, 0.5, 0.0),
            new Vec3d(0.75, 0.5, 1.0),
            new Vec3d(0.0, 0.5, 0.25),
            new Vec3d(0.0, 0.5, 0.75),
            new Vec3d(1.0, 0.5, 0.25),
            new Vec3d(1.0, 0.5, 0.75),
            new Vec3d(0.25, 0.0, 0.25),
            new Vec3d(0.25, 0.0, 0.75),
            new Vec3d(0.75, 0.0, 0.25),
            new Vec3d(0.75, 0.0, 0.75),
            new Vec3d(0.25, 1.0, 0.25),
            new Vec3d(0.25, 1.0, 0.75),
            new Vec3d(0.75, 1.0, 0.25),
            new Vec3d(0.75, 1.0, 0.75),
            new Vec3d(0.5, 0.25, 0.25),
            new Vec3d(0.5, 0.25, 0.75),
            new Vec3d(0.5, 0.75, 0.25),
            new Vec3d(0.5, 0.75, 0.75),
    };

    public static Vec3d getBestVisiblePoint2(Vec3d pos, Entity entity) {
        if (entity == null) {
            return null;
        }

        Box entityBox = entity.getBoundingBox();
        double closestDistance = Double.MAX_VALUE;
        Vec3d closestPoint = null;

        for (Vec3d point : PRECOMPUTED_POINTS) {
            Vec3d transformedPoint = new Vec3d(
                    entityBox.minX + point.x * (entityBox.maxX - entityBox.minX),
                    entityBox.minY + point.y * (entityBox.maxY - entityBox.minY),
                    entityBox.minZ + point.z * (entityBox.maxZ - entityBox.minZ)
            );

            if (isVisible(pos, transformedPoint)) {
                double distance = pos.squaredDistanceTo(transformedPoint);
                if (distance < closestDistance) {
                    closestDistance = distance;
                    closestPoint = transformedPoint;
                }
            }
        }

        if (closestPoint == null) {
            return getSpot(mc.player.getEyePos(), entity);
        }

        return closestPoint;
    }

    private static void addCorners(Box boundingBox, List<Vec3d> points) {
        points.add(new Vec3d(boundingBox.minX, boundingBox.minY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.minY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.maxY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.minY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ));
    }

    private static void addVerticalPoints(Box boundingBox, List<Vec3d> points, double x, int divisions) {
        for (int i = 0; i <= divisions; i++) {
            double y = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * i / divisions;
            points.add(new Vec3d(x, y, boundingBox.minZ));
            points.add(new Vec3d(x, y, boundingBox.maxZ));
        }
    }

    private static void addHorizontalPoints(Box boundingBox, List<Vec3d> points, double z, int divisions) {
        for (int i = 0; i <= divisions; i++) {
            double y = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * i / divisions;
            points.add(new Vec3d(boundingBox.minX, y, z));
            points.add(new Vec3d(boundingBox.maxX, y, z));
        }
    }

    public static boolean isVisible(Vec3d from, Vec3d to) {
        HitResult hitResult = mc.world.raycast(new RaycastContext(from, to, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, mc.player));
        return hitResult == null || hitResult.getType() == HitResult.Type.MISS;
    }
Пожалуйста, авторизуйтесь для просмотра ссылки.
как вы пишите рект я не понимаю на фабрике темболее 1.21.1
 
🪐 saturn solutions
Пользователь
Статус
Оффлайн
Регистрация
7 Апр 2019
Сообщения
300
Реакции[?]
34
Поинты[?]
8K
бебра:
public static Vec3d getAdaptivePoint(Entity entity) {
        Vec3d eyePos = mc.player.getEyePos();
        Vec3d playerPos = mc.player.getPos();

        Vec3d basePoint = getSpot(eyePos, entity);
        Vec3d multiPoint = getBestVisiblePoint2(eyePos, entity);

        boolean isBasePointVisible = isVisible(eyePos, basePoint);
        boolean isMultiPointVisible = isVisible(eyePos, multiPoint);

        double distToMultiPoint = multiPoint.squaredDistanceTo(playerPos);
        double distToBasePoint = basePoint.squaredDistanceTo(playerPos);

        if (isMultiPointVisible && isBasePointVisible) {
            return distToMultiPoint < distToBasePoint ? multiPoint : basePoint;
        } else if (isMultiPointVisible) {
            return multiPoint;
        } else if (isBasePointVisible) {
            return basePoint;
        } else {
            Vec3d entityCenter = entity.getBoundingBox().getCenter();
            boolean isMultiPointVisibleFromCenter = isVisible(entityCenter, multiPoint);
            boolean isBasePointVisibleFromCenter = isVisible(entityCenter, basePoint);

            if (isMultiPointVisibleFromCenter && !isBasePointVisibleFromCenter) {
                return multiPoint;
            } else if (!isMultiPointVisibleFromCenter && isBasePointVisibleFromCenter) {
                return basePoint;
            } else {
                return distToMultiPoint < distToBasePoint ? multiPoint : basePoint;
            }
        }
    }

    public static Vec3d getBestVisiblePoint(Vec3d pos, Entity entity, int p) {
        if (entity == null) return new Vec3d(0.0D, 0.0D, 0.0D);

        Vec3d closestPoint = null;
        double closestDistance = Double.MAX_VALUE;

        Box boundingBox = entity.getBoundingBox();
        List<Vec3d> points = new ArrayList<>();

        addCorners(boundingBox, points);

        // чем больше "p", тем больше точек, но меньше фпс

        for (double x : new double[]{boundingBox.minX, boundingBox.maxX}) {
            addVerticalPoints(boundingBox, points, x, p);
        }

        for (double z : new double[]{boundingBox.minZ, boundingBox.maxZ}) {
            addHorizontalPoints(boundingBox, points, z, p);
        }

        for (int i = 0; i <= p; i++) {
            double x = boundingBox.minX + (boundingBox.maxX - boundingBox.minX) * i / p;
            points.add(new Vec3d(x, boundingBox.minY, boundingBox.minZ));
            points.add(new Vec3d(x, boundingBox.minY, boundingBox.maxZ));
            points.add(new Vec3d(x, boundingBox.maxY, boundingBox.minZ));
            points.add(new Vec3d(x, boundingBox.maxY, boundingBox.maxZ));
        }

        points.add(new Vec3d((boundingBox.minX + boundingBox.maxX) / 2,
                (boundingBox.minY + boundingBox.maxY) / 2,
                (boundingBox.minZ + boundingBox.maxZ) / 2));

        for (Vec3d point : points) {
            if (isVisible(pos, point)) {
                double distance = pos.squaredDistanceTo(point);
                if (distance < closestDistance) {
                    closestDistance = distance;
                    closestPoint = point;
                }
            }
        }

        return closestPoint != null ? closestPoint : new Vec3d(0.0D, 0.0D, 0.0D);
    }

    public static final Vec3d[] PRECOMPUTED_POINTS = {
            new Vec3d(0.0, 0.0, 0.0),
            new Vec3d(0.0, 0.0, 1.0),
            new Vec3d(0.0, 1.0, 0.0),
            new Vec3d(0.0, 1.0, 1.0),
            new Vec3d(1.0, 0.0, 0.0),
            new Vec3d(1.0, 0.0, 1.0),
            new Vec3d(1.0, 1.0, 0.0),
            new Vec3d(1.0, 1.0, 1.0),
            new Vec3d(0.0, 0.0, 0.5),
            new Vec3d(0.0, 0.5, 0.0),
            new Vec3d(0.0, 0.5, 1.0),
            new Vec3d(0.0, 1.0, 0.5),
            new Vec3d(0.5, 0.0, 0.0),
            new Vec3d(0.5, 0.0, 1.0),
            new Vec3d(0.5, 1.0, 0.0),
            new Vec3d(0.5, 1.0, 1.0),
            new Vec3d(1.0, 0.0, 0.5),
            new Vec3d(1.0, 0.5, 0.0),
            new Vec3d(1.0, 0.5, 1.0),
            new Vec3d(1.0, 1.0, 0.5),
            new Vec3d(0.5, 0.5, 0.0),
            new Vec3d(0.5, 0.5, 1.0),
            new Vec3d(0.0, 0.5, 0.5),
            new Vec3d(1.0, 0.5, 0.5),
            new Vec3d(0.5, 0.0, 0.5),
            new Vec3d(0.5, 1.0, 0.5),
            new Vec3d(0.25, 0.25, 0.25),
            new Vec3d(0.25, 0.25, 0.75),
            new Vec3d(0.25, 0.75, 0.25),
            new Vec3d(0.25, 0.75, 0.75),
            new Vec3d(0.75, 0.25, 0.25),
            new Vec3d(0.75, 0.25, 0.75),
            new Vec3d(0.75, 0.75, 0.25),
            new Vec3d(0.75, 0.75, 0.75),
            new Vec3d(0.0, 0.25, 0.0),
            new Vec3d(0.0, 0.25, 1.0),
            new Vec3d(0.0, 0.75, 0.0),
            new Vec3d(0.0, 0.75, 1.0),
            new Vec3d(1.0, 0.25, 0.0),
            new Vec3d(1.0, 0.25, 1.0),
            new Vec3d(1.0, 0.75, 0.0),
            new Vec3d(1.0, 0.75, 1.0),
            new Vec3d(0.25, 0.0, 0.0),
            new Vec3d(0.25, 0.0, 1.0),
            new Vec3d(0.25, 1.0, 0.0),
            new Vec3d(0.25, 1.0, 1.0),
            new Vec3d(0.75, 0.0, 0.0),
            new Vec3d(0.75, 0.0, 1.0),
            new Vec3d(0.75, 1.0, 0.0),
            new Vec3d(0.75, 1.0, 1.0),
            new Vec3d(0.125, 0.125, 0.125),
            new Vec3d(0.125, 0.125, 0.875),
            new Vec3d(0.125, 0.875, 0.125),
            new Vec3d(0.125, 0.875, 0.875),
            new Vec3d(0.875, 0.125, 0.125),
            new Vec3d(0.875, 0.125, 0.875),
            new Vec3d(0.875, 0.875, 0.125),
            new Vec3d(0.875, 0.875, 0.875),
            new Vec3d(0.333, 0.333, 0.333),
            new Vec3d(0.333, 0.333, 0.666),
            new Vec3d(0.333, 0.666, 0.333),
            new Vec3d(0.333, 0.666, 0.666),
            new Vec3d(0.666, 0.333, 0.333),
            new Vec3d(0.666, 0.333, 0.666),
            new Vec3d(0.666, 0.666, 0.333),
            new Vec3d(0.666, 0.666, 0.666),
            new Vec3d(0.0, 0.333, 0.0),
            new Vec3d(0.0, 0.333, 1.0),
            new Vec3d(0.0, 0.666, 0.0),
            new Vec3d(0.0, 0.666, 1.0),
            new Vec3d(1.0, 0.333, 0.0),
            new Vec3d(1.0, 0.333, 1.0),
            new Vec3d(1.0, 0.666, 0.0),
            new Vec3d(1.0, 0.666, 1.0),
            new Vec3d(0.333, 0.0, 0.0),
            new Vec3d(0.333, 0.0, 1.0),
            new Vec3d(0.333, 1.0, 0.0),
            new Vec3d(0.333, 1.0, 1.0),
            new Vec3d(0.666, 0.0, 0.0),
            new Vec3d(0.666, 0.0, 1.0),
            new Vec3d(0.666, 1.0, 0.0),
            new Vec3d(0.666, 1.0, 1.0),
            new Vec3d(0.0, 0.0, 0.25),
            new Vec3d(0.0, 0.0, 0.75),
            new Vec3d(1.0, 0.0, 0.25),
            new Vec3d(1.0, 0.0, 0.75),
            new Vec3d(0.0, 1.0, 0.25),
            new Vec3d(0.0, 1.0, 0.75),
            new Vec3d(1.0, 1.0, 0.25),
            new Vec3d(1.0, 1.0, 0.75),
            new Vec3d(0.5, 0.5, 0.25),
            new Vec3d(0.5, 0.5, 0.75),
            new Vec3d(0.25, 0.25, 0.0),
            new Vec3d(0.25, 0.25, 1.0),
            new Vec3d(0.75, 0.75, 0.0),
            new Vec3d(0.75, 0.75, 1.0),
            new Vec3d(0.5, 0.25, 0.0),
            new Vec3d(0.5, 0.25, 1.0),
            new Vec3d(0.5, 0.75, 0.0),
            new Vec3d(0.5, 0.75, 1.0),
            new Vec3d(0.25, 0.5, 0.0),
            new Vec3d(0.25, 0.5, 1.0),
            new Vec3d(0.75, 0.5, 0.0),
            new Vec3d(0.75, 0.5, 1.0),
            new Vec3d(0.0, 0.5, 0.25),
            new Vec3d(0.0, 0.5, 0.75),
            new Vec3d(1.0, 0.5, 0.25),
            new Vec3d(1.0, 0.5, 0.75),
            new Vec3d(0.25, 0.0, 0.25),
            new Vec3d(0.25, 0.0, 0.75),
            new Vec3d(0.75, 0.0, 0.25),
            new Vec3d(0.75, 0.0, 0.75),
            new Vec3d(0.25, 1.0, 0.25),
            new Vec3d(0.25, 1.0, 0.75),
            new Vec3d(0.75, 1.0, 0.25),
            new Vec3d(0.75, 1.0, 0.75),
            new Vec3d(0.5, 0.25, 0.25),
            new Vec3d(0.5, 0.25, 0.75),
            new Vec3d(0.5, 0.75, 0.25),
            new Vec3d(0.5, 0.75, 0.75),
    };

    public static Vec3d getBestVisiblePoint2(Vec3d pos, Entity entity) {
        if (entity == null) {
            return null;
        }

        Box entityBox = entity.getBoundingBox();
        double closestDistance = Double.MAX_VALUE;
        Vec3d closestPoint = null;

        for (Vec3d point : PRECOMPUTED_POINTS) {
            Vec3d transformedPoint = new Vec3d(
                    entityBox.minX + point.x * (entityBox.maxX - entityBox.minX),
                    entityBox.minY + point.y * (entityBox.maxY - entityBox.minY),
                    entityBox.minZ + point.z * (entityBox.maxZ - entityBox.minZ)
            );

            if (isVisible(pos, transformedPoint)) {
                double distance = pos.squaredDistanceTo(transformedPoint);
                if (distance < closestDistance) {
                    closestDistance = distance;
                    closestPoint = transformedPoint;
                }
            }
        }

        if (closestPoint == null) {
            return getSpot(mc.player.getEyePos(), entity);
        }

        return closestPoint;
    }

    private static void addCorners(Box boundingBox, List<Vec3d> points) {
        points.add(new Vec3d(boundingBox.minX, boundingBox.minY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.minY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.maxY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.minY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ));
        points.add(new Vec3d(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ));
    }

    private static void addVerticalPoints(Box boundingBox, List<Vec3d> points, double x, int divisions) {
        for (int i = 0; i <= divisions; i++) {
            double y = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * i / divisions;
            points.add(new Vec3d(x, y, boundingBox.minZ));
            points.add(new Vec3d(x, y, boundingBox.maxZ));
        }
    }

    private static void addHorizontalPoints(Box boundingBox, List<Vec3d> points, double z, int divisions) {
        for (int i = 0; i <= divisions; i++) {
            double y = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * i / divisions;
            points.add(new Vec3d(boundingBox.minX, y, z));
            points.add(new Vec3d(boundingBox.maxX, y, z));
        }
    }

    public static boolean isVisible(Vec3d from, Vec3d to) {
        HitResult hitResult = mc.world.raycast(new RaycastContext(from, to, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, mc.player));
        return hitResult == null || hitResult.getType() == HitResult.Type.MISS;
    }
Пожалуйста, авторизуйтесь для просмотра ссылки.
какие нахуй мультипоинты на майнкрафт?? квадратоголовые вы ебанулись? рапид файр еще напишите с десинками
 
Начинающий
Статус
Оффлайн
Регистрация
18 Авг 2023
Сообщения
376
Реакции[?]
2
Поинты[?]
1K
Сверху Снизу