Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Визуальная часть ItemRadius | Premium 1.21.4

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
12 Янв 2025
Сообщения
33
Реакции
1
Выберите загрузчик игры
  1. Fabric
Всем привет знаю уже куча была про это тем но это первая тема где если держать сахар то не будет думать что явная пыль и так с другими. :pepe8:

Java:
Expand Collapse Copy
public class ItemRadius extends Module {

    private final MultiBooleanSetting items = new MultiBooleanSetting(
            "Предметы",
            new BooleanSetting("Дезка", true),
            new BooleanSetting("Явка", true),
            new BooleanSetting("Огненый Заряд", true),
            new BooleanSetting("Божья Аура", true),
            new BooleanSetting("Трапка", true),
            new BooleanSetting("Пласт", true)
    );

    private int currentOutlineColor = 0xFFFFFFFF;
    private int targetOutlineColor = 0xFFFFFFFF;
    private float transitionTimer = 0.0f;
    private boolean lastPlayersInRadius = false;
    private static final float TRANSITION_DURATION = 0.5f;

    private Vec3d plastSmoothedCenter = Vec3d.ZERO;
    private float plastSmoothedYawDeg = 0.0f;
    private float plastSmoothedPitchDeg = 0.0f;
    private boolean plastHasSmoothedPose = false;

    public ItemRadius() {
        addSettings(items);
    }

    @EventInit
    public void onRender3D(EventRender3D event) {
        if (!enable) return;
        if (mc.player == null || mc.world == null) return;

        ItemStack main = mc.player.getMainHandStack();
        ItemStack off = mc.player.getOffHandStack();

        boolean handled = false;

        if (items.get("Дезка") && (isHolding(main, Items.ENDER_EYE) || isHolding(off, Items.ENDER_EYE))) {
            ItemStack eyeStack = isHolding(main, Items.ENDER_EYE) ? main : off;
            if (containsCyrillicLetter(eyeStack, 'Я')) {
                handled = true;
                float radius = 10.0f;
                Vec3d center = getCircleCenter(event.getTickDelta());
                boolean playersInRadius = checkPlayersInRadius(mc.player, center, radius);
                updateOutlineColor(playersInRadius, event.getTickDelta());
                if (playersInRadius) {
                    renderCircleFill(event, center, radius, 0x3300FF00);
                }
                renderCircleOutline(event, center, radius, currentOutlineColor);
            }
        }

        if (!handled && items.get("Явка") && (isHolding(main, Items.SUGAR) || isHolding(off, Items.SUGAR))) {
            ItemStack sugarStack = isHolding(main, Items.SUGAR) ? main : off;
            if (containsCyrillicLetter(sugarStack, 'Я')) {
                handled = true;
                float radius = 10.0f;
                Vec3d center = getCircleCenter(event.getTickDelta());
                boolean playersInRadius = checkPlayersInRadius(mc.player, center, radius);
                updateOutlineColor(playersInRadius, event.getTickDelta());
                if (playersInRadius) {
                    renderCircleFill(event, center, radius, 0x3300FF00);
                }
                renderCircleOutline(event, center, radius, currentOutlineColor);
            }
        }

        if (!handled && items.get("Огненый Заряд") && (isHolding(main, Items.FIRE_CHARGE) || isHolding(off, Items.FIRE_CHARGE))) {
            ItemStack fireChargeStack = isHolding(main, Items.FIRE_CHARGE) ? main : off;
            if (containsCyrillicLetter(fireChargeStack, 'С')) {
                handled = true;
                float radius = 10.0f;
                Vec3d center = getCircleCenter(event.getTickDelta());
                boolean playersInRadius = checkPlayersInRadius(mc.player, center, radius);
                updateOutlineColor(playersInRadius, event.getTickDelta());
                if (playersInRadius) {
                    renderCircleFill(event, center, radius, 0x3300FF00);
                }
                renderCircleOutline(event, center, radius, currentOutlineColor);
            }
        }

        if (!handled && items.get("Божья Аура") && (isHolding(main, Items.PHANTOM_MEMBRANE) || isHolding(off, Items.PHANTOM_MEMBRANE))) {
            ItemStack membraneStack = isHolding(main, Items.PHANTOM_MEMBRANE) ? main : off;
            if (containsCyrillicLetter(membraneStack, 'У')) {
                handled = true;
                float radius = 2.0f;
                Vec3d center = getCircleCenter(event.getTickDelta());
                boolean playersInRadius = checkPlayersInRadius(mc.player, center, radius);
                boolean friendsInRadius = checkFriendsInRadius(mc.player, center, radius);
                updateOutlineColor(playersInRadius, event.getTickDelta());
                if (friendsInRadius) {
                    renderCircleFill(event, center, radius, 0x3300FF00);
                }
                renderCircleOutline(event, center, radius, currentOutlineColor);
            }
        }

        if (!handled && items.get("Трапка") && (isHolding(main, Items.NETHERITE_SCRAP) || isHolding(off, Items.NETHERITE_SCRAP))) {
            ItemStack scrapStack = isHolding(main, Items.NETHERITE_SCRAP) ? main : off;
            if (containsCyrillicLetter(scrapStack, 'А')) {
                handled = true;
                Vec3d p = getLerpedPlayerPos(event.getTickDelta());
                Vec3d cubeCenter = new Vec3d(
                        p.x,
                        p.y + 0.5 + 1.625,
                        p.z
                );
                boolean playersInRadius = checkPlayersInRadius(mc.player, cubeCenter, 2.5);
                updateOutlineColor(playersInRadius, event.getTickDelta());
                renderCubeOutline(event, cubeCenter, 4.0f, currentOutlineColor);
            }
        }

        if (!handled && items.get("Пласт") && (isHolding(main, Items.DRIED_KELP) || isHolding(off, Items.DRIED_KELP))) {
            ItemStack kelpStack = isHolding(main, Items.DRIED_KELP) ? main : off;
            if (containsCyrillicLetter(kelpStack, 'П')) {
                handled = true;
                PlanePose pose = smoothPlastPose(computePlanePose(event.getTickDelta()), event.getTickDelta());
                boolean playersInRadius = checkPlayersInRadius(mc.player, pose.center, 2.5);
                if (playersInRadius) {
                    renderPlaneFill(event, pose, 0x66FF0000);
                    renderPlaneOutline(event, pose, 0xFFFF0000);
                } else {
                    renderPlaneOutline(event, pose, 0xFF00FF00);
                }
            }
        }

        if (!handled) {
            plastHasSmoothedPose = false;
        }
    }

    private void renderCircleFill(EventRender3D event, Vec3d center, float radius, int fillColor) {
        if (mc.player == null) return;

        BufferAllocator allocator = new BufferAllocator(1 << 16);
        VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(allocator);
        try {
            Matrix4f matrix = event.getMatrixStack().peek().getPositionMatrix();
            Vec3d camera = mc.gameRenderer.getCamera().getPos();
            VertexConsumer buffer = immediate.getBuffer(ITEM_RADIUS_CIRCLE_FILL_LAYER);

            float y = (float) (center.y + mc.player.getHeight());
            float cx = (float) (center.x - camera.x);
            float cy = (float) (y - camera.y);
            float cz = (float) (center.z - camera.z);

            int r = (fillColor >> 16) & 0xFF;
            int g = (fillColor >> 8) & 0xFF;
            int b = fillColor & 0xFF;
            int a = (fillColor >> 24) & 0xFF;

            int stepDeg = 5;
            float prevX = 0.0f;
            float prevZ = 0.0f;
            boolean hasPrev = false;

            for (int deg = 0; deg <= 360; deg += stepDeg) {
                double rad = Math.toRadians(deg);
                float x = cx + (float) (MathHelper.sin((float) rad) * radius);
                float z = cz + (float) (-MathHelper.cos((float) rad) * radius);

                if (!hasPrev) {
                    prevX = x;
                    prevZ = z;
                    hasPrev = true;
                    continue;
                }

                buffer.vertex(matrix, cx, cy, cz).color(r, g, b, a);
                buffer.vertex(matrix, prevX, cy, prevZ).color(r, g, b, a);
                buffer.vertex(matrix, x, cy, z).color(r, g, b, a);

                prevX = x;
                prevZ = z;
            }

            immediate.draw();
        } finally {
            allocator.close();
        }
    }

    private PlanePose smoothPlastPose(PlanePose target, float tickDelta) {
        if (!plastHasSmoothedPose) {
            plastSmoothedCenter = target.center;
            plastSmoothedYawDeg = target.yawDeg;
            plastSmoothedPitchDeg = target.pitchDeg;
            plastHasSmoothedPose = true;
            return target;
        }

        float speed = 12.0f;
        float t = 1.0f - (float) Math.exp(-speed * Math.max(0.0f, tickDelta));

        plastSmoothedCenter = plastSmoothedCenter.lerp(target.center, t);
        plastSmoothedYawDeg = lerpAngleDeg(plastSmoothedYawDeg, target.yawDeg, t);
        plastSmoothedPitchDeg = lerpAngleDeg(plastSmoothedPitchDeg, target.pitchDeg, t);

        return new PlanePose(plastSmoothedCenter, plastSmoothedYawDeg, plastSmoothedPitchDeg);
    }

    private static float lerpAngleDeg(float from, float to, float t) {
        float delta = MathHelper.wrapDegrees(to - from);
        return from + delta * t;
    }

    private void updateOutlineColor(boolean playersInRadius, float tickDelta) {
        if (playersInRadius != lastPlayersInRadius) {
            transitionTimer = 0.0f;
            lastPlayersInRadius = playersInRadius;
        }

        int baseOutline = 0xFFFFFFFF;
        int lightOutline = 0xFF00FF00;
        targetOutlineColor = playersInRadius ? lightOutline : baseOutline;

        float step = TRANSITION_DURATION <= 0.0001f ? 1.0f : (tickDelta / TRANSITION_DURATION);
        transitionTimer = Math.min(transitionTimer + step, 1.0f);
        currentOutlineColor = lerpColor(currentOutlineColor, targetOutlineColor, transitionTimer);
    }

    private static int lerpColor(int startColor, int endColor, float t) {
        int startA = (startColor >> 24) & 0xFF;
        int startR = (startColor >> 16) & 0xFF;
        int startG = (startColor >> 8) & 0xFF;
        int startB = startColor & 0xFF;

        int endA = (endColor >> 24) & 0xFF;
        int endR = (endColor >> 16) & 0xFF;
        int endG = (endColor >> 8) & 0xFF;
        int endB = endColor & 0xFF;

        int a = (int) (startA + (endA - startA) * t);
        int r = (int) (startR + (endR - startR) * t);
        int g = (int) (startG + (endG - startG) * t);
        int b = (int) (startB + (endB - startB) * t);

        return (a << 24) | (r << 16) | (g << 8) | b;
    }

    private static boolean isHolding(ItemStack stack, Item item) {
        return stack != null && !stack.isEmpty() && stack.isOf(item);
    }

    private static boolean containsCyrillicLetter(ItemStack stack, char letter) {
        if (stack == null || stack.isEmpty()) return false;
        String name = stack.getName().getString();
        if (name == null || name.isEmpty()) return false;
        String upper = name.toUpperCase();
        return upper.indexOf(Character.toUpperCase(letter)) >= 0;
    }

    private boolean checkPlayersInRadius(PlayerEntity self, Vec3d centerPos, double radius) {
        if (mc.world == null) return false;
        double r2 = radius * radius;
        for (PlayerEntity p : mc.world.getPlayers()) {
            if (p == null || p == self) continue;
            if (p.squaredDistanceTo(centerPos) <= r2) {
                return true;
            }
        }
        return false;
    }

    private boolean checkFriendsInRadius(PlayerEntity self, Vec3d centerPos, double radius) {
        if (mc.world == null) return false;
        if (Strange.get == null || Strange.get.friendManager == null) return false;

        double r2 = radius * radius;
        for (PlayerEntity p : mc.world.getPlayers()) {
            if (p == null || p == self) continue;
            if (p.squaredDistanceTo(centerPos) > r2) continue;

            String name = p.getName().getString();
            if (name != null && Strange.get.friendManager.isFriend(name)) {
                return true;
            }
        }
        return false;
    }

    private Vec3d getLerpedPlayerPos(float tickDelta) {
        if (mc.player == null) return Vec3d.ZERO;
        double x = mc.player.lastRenderX + (mc.player.getX() - mc.player.lastRenderX) * tickDelta;
        double y = mc.player.lastRenderY + (mc.player.getY() - mc.player.lastRenderY) * tickDelta;
        double z = mc.player.lastRenderZ + (mc.player.getZ() - mc.player.lastRenderZ) * tickDelta;
        return new Vec3d(x, y, z);
    }

    private Vec3d getCircleCenter(float tickDelta) {
        Vec3d pos = getLerpedPlayerPos(tickDelta);
        return pos.add(0.0, -1.4, 0.0);
    }

    private void renderCircleOutline(EventRender3D event, Vec3d center, float radius, int outlineColor) {
        if (mc.player == null) return;

        BufferAllocator allocator = new BufferAllocator(1 << 16);
        VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(allocator);
        try {
            Matrix4f matrix = event.getMatrixStack().peek().getPositionMatrix();
            Vec3d camera = mc.gameRenderer.getCamera().getPos();

            VertexConsumer buffer = immediate.getBuffer(ITEM_RADIUS_LINE_LAYER);

            float y = (float) (center.y + mc.player.getHeight());
            float cx = (float) (center.x - camera.x);
            float cy = (float) (y - camera.y);
            float cz = (float) (center.z - camera.z);

            int r = (outlineColor >> 16) & 0xFF;
            int g = (outlineColor >> 8) & 0xFF;
            int b = outlineColor & 0xFF;
            int a = (outlineColor >> 24) & 0xFF;

            int stepDeg = 5;
            float firstX = 0.0f;
            float firstZ = 0.0f;
            float prevX = 0.0f;
            float prevZ = 0.0f;
            boolean hasPrev = false;

            for (int deg = 0; deg <= 360; deg += stepDeg) {
                double rad = Math.toRadians(deg);
                float x = cx + (float) (MathHelper.sin((float) rad) * radius);
                float z = cz + (float) (-MathHelper.cos((float) rad) * radius);

                if (!hasPrev) {
                    firstX = x;
                    firstZ = z;
                    prevX = x;
                    prevZ = z;
                    hasPrev = true;
                    continue;
                }

                buffer.vertex(matrix, prevX, cy, prevZ).color(r, g, b, a);
                buffer.vertex(matrix, x, cy, z).color(r, g, b, a);

                prevX = x;
                prevZ = z;
            }

            if (hasPrev) {
                buffer.vertex(matrix, prevX, cy, prevZ).color(r, g, b, a);
                buffer.vertex(matrix, firstX, cy, firstZ).color(r, g, b, a);
            }

            immediate.draw();
        } finally {
            allocator.close();
        }
    }

    private void renderPlaneFill(EventRender3D event, PlanePose pose, int fillColor) {
        BufferAllocator allocator = new BufferAllocator(1 << 16);
        VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(allocator);
        try {
            Vec3d camera = mc.gameRenderer.getCamera().getPos();
            VertexConsumer buffer = immediate.getBuffer(ITEM_RADIUS_FILL_LAYER);

            float width = 4.0f;
            float height = 4.0f;
            float thickness = 1.5f;

            float halfW = width / 2.0f;
            float halfH = height / 2.0f;
            float halfT = thickness / 2.0f;

            event.getMatrixStack().push();
            event.getMatrixStack().translate(pose.center.x - camera.x, pose.center.y - camera.y, pose.center.z - camera.z);

            if (Math.abs(pose.pitchDeg) > 0.001f) {
                event.getMatrixStack().multiply(net.minecraft.util.math.RotationAxis.POSITIVE_X.rotationDegrees(pose.pitchDeg));
            }
            if (Math.abs(pose.yawDeg) > 0.001f) {
                event.getMatrixStack().multiply(net.minecraft.util.math.RotationAxis.POSITIVE_Y.rotationDegrees(pose.yawDeg));
            }

            Matrix4f mat = event.getMatrixStack().peek().getPositionMatrix();

            float minX = -halfW;
            float maxX = halfW;
            float minY = -halfH;
            float maxY = halfH;
            float minZ = -halfT;
            float maxZ = halfT;

            drawBoxFaces(buffer, mat, minX, minY, minZ, maxX, maxY, maxZ, fillColor);
            event.getMatrixStack().pop();

            immediate.draw();
        } finally {
            allocator.close();
        }
    }

    private static void drawBoxFaces(VertexConsumer buffer, Matrix4f matrix,
                                     float minX, float minY, float minZ,
                                     float maxX, float maxY, float maxZ,
                                     int color) {
        int r = (color >> 16) & 0xFF;
        int g = (color >> 8) & 0xFF;
        int b = color & 0xFF;
        int a = (color >> 24) & 0xFF;

        buffer.vertex(matrix, minX, minY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, minY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, maxY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, maxY, maxZ).color(r, g, b, a);

        buffer.vertex(matrix, maxX, minY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, minY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, maxY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, maxY, minZ).color(r, g, b, a);

        buffer.vertex(matrix, minX, maxY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, maxY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, maxY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, maxY, minZ).color(r, g, b, a);

        buffer.vertex(matrix, minX, minY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, minY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, minY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, minY, maxZ).color(r, g, b, a);

        buffer.vertex(matrix, minX, minY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, minY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, maxY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, maxY, minZ).color(r, g, b, a);

        buffer.vertex(matrix, maxX, minY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, minY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, maxY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, maxY, maxZ).color(r, g, b, a);
    }

    private void renderCubeOutline(EventRender3D event, Vec3d center, float size, int outlineColor) {
        BufferAllocator allocator = new BufferAllocator(1 << 16);
        VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(allocator);
        try {
            Matrix4f matrix = event.getMatrixStack().peek().getPositionMatrix();
            Vec3d camera = mc.gameRenderer.getCamera().getPos();
            VertexConsumer buffer = immediate.getBuffer(ITEM_RADIUS_CUBE_LINE_LAYER);

            float half = size / 2.0f;
            float minX = (float) (center.x - camera.x - half);
            float minY = (float) (center.y - camera.y - half);
            float minZ = (float) (center.z - camera.z - half);
            float maxX = minX + size;
            float maxY = minY + size;
            float maxZ = minZ + size;

            drawBoxEdges(buffer, matrix, minX, minY, minZ, maxX, maxY, maxZ, outlineColor);
            immediate.draw();
        } finally {
            allocator.close();
        }
    }

    private static void drawBoxEdges(VertexConsumer buffer, Matrix4f matrix,
                                     float minX, float minY, float minZ,
                                     float maxX, float maxY, float maxZ,
                                     int color) {
        drawLine(buffer, matrix, minX, minY, minZ, maxX, minY, minZ, color);
        drawLine(buffer, matrix, maxX, minY, minZ, maxX, minY, maxZ, color);
        drawLine(buffer, matrix, maxX, minY, maxZ, minX, minY, maxZ, color);
        drawLine(buffer, matrix, minX, minY, maxZ, minX, minY, minZ, color);

        drawLine(buffer, matrix, minX, maxY, minZ, maxX, maxY, minZ, color);
        drawLine(buffer, matrix, maxX, maxY, minZ, maxX, maxY, maxZ, color);
        drawLine(buffer, matrix, maxX, maxY, maxZ, minX, maxY, maxZ, color);
        drawLine(buffer, matrix, minX, maxY, maxZ, minX, maxY, minZ, color);

        drawLine(buffer, matrix, minX, minY, minZ, minX, maxY, minZ, color);
        drawLine(buffer, matrix, maxX, minY, minZ, maxX, maxY, minZ, color);
        drawLine(buffer, matrix, maxX, minY, maxZ, maxX, maxY, maxZ, color);
        drawLine(buffer, matrix, minX, minY, maxZ, minX, maxY, maxZ, color);
    }

    private static void drawLine(VertexConsumer buffer, Matrix4f matrix,
                                 float x1, float y1, float z1,
                                 float x2, float y2, float z2,
                                 int color) {
        int r = (color >> 16) & 0xFF;
        int g = (color >> 8) & 0xFF;
        int b = color & 0xFF;
        int a = (color >> 24) & 0xFF;
        buffer.vertex(matrix, x1, y1, z1).color(r, g, b, a);
        buffer.vertex(matrix, x2, y2, z2).color(r, g, b, a);
    }

    private record PlanePose(Vec3d center, float yawDeg, float pitchDeg) {
    }

    private PlanePose computePlanePose(float tickDelta) {
        Vec3d playerPos = getLerpedPlayerPos(tickDelta);
        Vec3d start = playerPos.add(0.0, mc.player.getEyeHeight(mc.player.getPose()), 0.0);
        Vec3d lookVec = mc.player.getRotationVec(tickDelta);
        Vec3d end = start.add(lookVec.multiply(4.0));

        BlockHitResult hit = mc.world.raycast(new RaycastContext(
                start,
                end,
                RaycastContext.ShapeType.COLLIDER,
                RaycastContext.FluidHandling.NONE,
                mc.player
        ));

        float pitch = mc.player.getPitch(tickDelta);
        boolean isLookingDown = pitch > 45.0f;
        boolean isLookingUp = pitch < -45.0f;
        boolean isLookingHorizontal = !isLookingDown && !isLookingUp;

        float thickness = 1.5f;
        float halfThickness = thickness / 2.0f;

        Vec3d center;
        float yawDeg;
        float pitchDeg;

        if (hit.getType() == HitResult.Type.BLOCK && hit.getPos().distanceTo(start) <= 4.0) {
            Vec3d hitPos = hit.getPos();
            Direction face = hit.getSide();

            if (isLookingDown) {
                center = new Vec3d(
                        Math.floor(hitPos.x) + 0.5,
                        Math.floor(hitPos.y + 1.0) - 1.8 + halfThickness,
                        Math.floor(hitPos.z) + 0.5
                );
                yawDeg = 0.0f;
                pitchDeg = 90.0f;
            } else if (isLookingUp) {
                center = new Vec3d(
                        Math.floor(hitPos.x) + 0.5,
                        Math.floor(hitPos.y) - halfThickness + 1.6,
                        Math.floor(hitPos.z) + 0.5
                );
                yawDeg = 0.0f;
                pitchDeg = -90.0f;
            } else {
                double offsetX = face.getOffsetX() != 0 ? face.getOffsetX() * halfThickness : 0.0;
                double offsetZ = face.getOffsetZ() != 0 ? face.getOffsetZ() * halfThickness : 0.0;
                center = new Vec3d(
                        Math.floor(hitPos.x) + 0.5 + offsetX,
                        Math.floor(hitPos.y) + 0.5 + 1.6,
                        Math.floor(hitPos.z) + 0.5 + offsetZ
                );

                yawDeg = switch (face) {
                    case NORTH -> 180.0f;
                    case SOUTH -> 0.0f;
                    case WEST -> 90.0f;
                    case EAST -> -90.0f;
                    default -> -mc.player.getYaw(tickDelta);
                };
                pitchDeg = 0.0f;
            }
        } else {
            Vec3d approx = start.add(lookVec.multiply(4.0));
            double y = Math.floor(approx.y) + (isLookingDown ? (-1.8 + halfThickness) : isLookingUp ? (-halfThickness + 1.6) : (0.5 + 1.6));
            center = new Vec3d(Math.floor(approx.x) + 0.5, y, Math.floor(approx.z) + 0.5);
            yawDeg = -mc.player.getYaw(tickDelta);
            pitchDeg = 0.0f;
        }

        if (!isLookingHorizontal) {
            yawDeg = -mc.player.getYaw(tickDelta);
        }

        return new PlanePose(center, yawDeg, pitchDeg);
    }

    private void renderPlaneOutline(EventRender3D event, PlanePose pose, int outlineColor) {
        BufferAllocator allocator = new BufferAllocator(1 << 16);
        VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(allocator);
        try {
            Matrix4f matrix = event.getMatrixStack().peek().getPositionMatrix();
            Vec3d camera = mc.gameRenderer.getCamera().getPos();
            VertexConsumer buffer = immediate.getBuffer(ITEM_RADIUS_LINE_LAYER);

            float width = 4.0f;
            float height = 4.0f;
            float thickness = 1.5f;

            float halfW = width / 2.0f;
            float halfH = height / 2.0f;
            float halfT = thickness / 2.0f;

            event.getMatrixStack().push();
            event.getMatrixStack().translate(pose.center.x - camera.x, pose.center.y - camera.y, pose.center.z - camera.z);

            if (Math.abs(pose.pitchDeg) > 0.001f) {
                event.getMatrixStack().multiply(net.minecraft.util.math.RotationAxis.POSITIVE_X.rotationDegrees(pose.pitchDeg));
            }
            if (Math.abs(pose.yawDeg) > 0.001f) {
                event.getMatrixStack().multiply(net.minecraft.util.math.RotationAxis.POSITIVE_Y.rotationDegrees(pose.yawDeg));
            }

            Matrix4f mat = event.getMatrixStack().peek().getPositionMatrix();

            float minX = -halfW;
            float maxX = halfW;
            float minY = -halfH;
            float maxY = halfH;
            float minZ = -halfT;
            float maxZ = halfT;

            drawBoxEdges(buffer, mat, minX, minY, minZ, maxX, maxY, maxZ, outlineColor);
            event.getMatrixStack().pop();

            immediate.draw();
        } finally {
            allocator.close();
        }
    }

    private static final int LINE_BUFFER_SIZE_BYTES = 1 << 10;

    private static final RenderPipeline ITEM_RADIUS_LINE_PIPELINE = RenderPipelines.register(
            RenderPipeline.builder(RenderPipelines.POSITION_COLOR_SNIPPET)
                    .withLocation(Identifier.of("strange", "pipeline/world/item_radius_lines"))
                    .withVertexFormat(VertexFormats.POSITION_COLOR, VertexFormat.DrawMode.DEBUG_LINES)
                    .withCull(false)
                    .withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST)
                    .withDepthWrite(false)
                    .withBlend(BlendFunction.LIGHTNING)
                    .build()
    );

    private static final RenderLayer ITEM_RADIUS_LINE_LAYER = RenderLayer.of(
            "strange_item_radius_lines",
            LINE_BUFFER_SIZE_BYTES,
            false,
            true,
            ITEM_RADIUS_LINE_PIPELINE,
            RenderLayer.MultiPhaseParameters.builder()
                    .lineWidth(new RenderPhase.LineWidth(OptionalDouble.of(3.0)))
                    .build(false)
    );

    private static final RenderLayer ITEM_RADIUS_CUBE_LINE_LAYER = RenderLayer.of(
            "strange_item_radius_cube_lines",
            LINE_BUFFER_SIZE_BYTES,
            false,
            true,
            ITEM_RADIUS_LINE_PIPELINE,
            RenderLayer.MultiPhaseParameters.builder()
                    .lineWidth(new RenderPhase.LineWidth(OptionalDouble.of(6.0)))
                    .build(false)
    );

    private static final RenderPipeline ITEM_RADIUS_CIRCLE_FILL_PIPELINE = RenderPipelines.register(
            RenderPipeline.builder(RenderPipelines.POSITION_COLOR_SNIPPET)
                    .withLocation(Identifier.of("strange", "pipeline/world/item_radius_circle_fill"))
                    .withVertexFormat(VertexFormats.POSITION_COLOR, VertexFormat.DrawMode.TRIANGLES)
                    .withCull(false)
                    .withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST)
                    .withDepthWrite(false)
                    .withBlend(BlendFunction.LIGHTNING)
                    .build()
    );

    private static final RenderLayer ITEM_RADIUS_CIRCLE_FILL_LAYER = RenderLayer.of(
            "strange_item_radius_circle_fill",
            LINE_BUFFER_SIZE_BYTES,
            false,
            true,
            ITEM_RADIUS_CIRCLE_FILL_PIPELINE,
            RenderLayer.MultiPhaseParameters.builder().build(false)
    );

    private static final RenderPipeline ITEM_RADIUS_FILL_PIPELINE = RenderPipelines.register(
            RenderPipeline.builder(RenderPipelines.POSITION_COLOR_SNIPPET)
                    .withLocation(Identifier.of("strange", "pipeline/world/item_radius_fill"))
                    .withVertexFormat(VertexFormats.POSITION_COLOR, VertexFormat.DrawMode.QUADS)
                    .withCull(false)
                    .withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST)
                    .withDepthWrite(false)
                    .withBlend(BlendFunction.LIGHTNING)
                    .build()
    );

    private static final RenderLayer ITEM_RADIUS_FILL_LAYER = RenderLayer.of(
            "strange_item_radius_fill",
            LINE_BUFFER_SIZE_BYTES,
            false,
            true,
            ITEM_RADIUS_FILL_PIPELINE,
            RenderLayer.MultiPhaseParameters.builder().build(false)
    );
}
1771014453367.png
1771014460587.png
1771014465543.png
1771014470613.png
1771014474740.png

фу 700 строк кода гпт удаляй тему
 
Всем привет знаю уже куча была про это тем но это первая тема где если держать сахар то не будет думать что явная пыль и так с другими. :pepe8:

Java:
Expand Collapse Copy
public class ItemRadius extends Module {

    private final MultiBooleanSetting items = new MultiBooleanSetting(
            "Предметы",
            new BooleanSetting("Дезка", true),
            new BooleanSetting("Явка", true),
            new BooleanSetting("Огненый Заряд", true),
            new BooleanSetting("Божья Аура", true),
            new BooleanSetting("Трапка", true),
            new BooleanSetting("Пласт", true)
    );

    private int currentOutlineColor = 0xFFFFFFFF;
    private int targetOutlineColor = 0xFFFFFFFF;
    private float transitionTimer = 0.0f;
    private boolean lastPlayersInRadius = false;
    private static final float TRANSITION_DURATION = 0.5f;

    private Vec3d plastSmoothedCenter = Vec3d.ZERO;
    private float plastSmoothedYawDeg = 0.0f;
    private float plastSmoothedPitchDeg = 0.0f;
    private boolean plastHasSmoothedPose = false;

    public ItemRadius() {
        addSettings(items);
    }

    @EventInit
    public void onRender3D(EventRender3D event) {
        if (!enable) return;
        if (mc.player == null || mc.world == null) return;

        ItemStack main = mc.player.getMainHandStack();
        ItemStack off = mc.player.getOffHandStack();

        boolean handled = false;

        if (items.get("Дезка") && (isHolding(main, Items.ENDER_EYE) || isHolding(off, Items.ENDER_EYE))) {
            ItemStack eyeStack = isHolding(main, Items.ENDER_EYE) ? main : off;
            if (containsCyrillicLetter(eyeStack, 'Я')) {
                handled = true;
                float radius = 10.0f;
                Vec3d center = getCircleCenter(event.getTickDelta());
                boolean playersInRadius = checkPlayersInRadius(mc.player, center, radius);
                updateOutlineColor(playersInRadius, event.getTickDelta());
                if (playersInRadius) {
                    renderCircleFill(event, center, radius, 0x3300FF00);
                }
                renderCircleOutline(event, center, radius, currentOutlineColor);
            }
        }

        if (!handled && items.get("Явка") && (isHolding(main, Items.SUGAR) || isHolding(off, Items.SUGAR))) {
            ItemStack sugarStack = isHolding(main, Items.SUGAR) ? main : off;
            if (containsCyrillicLetter(sugarStack, 'Я')) {
                handled = true;
                float radius = 10.0f;
                Vec3d center = getCircleCenter(event.getTickDelta());
                boolean playersInRadius = checkPlayersInRadius(mc.player, center, radius);
                updateOutlineColor(playersInRadius, event.getTickDelta());
                if (playersInRadius) {
                    renderCircleFill(event, center, radius, 0x3300FF00);
                }
                renderCircleOutline(event, center, radius, currentOutlineColor);
            }
        }

        if (!handled && items.get("Огненый Заряд") && (isHolding(main, Items.FIRE_CHARGE) || isHolding(off, Items.FIRE_CHARGE))) {
            ItemStack fireChargeStack = isHolding(main, Items.FIRE_CHARGE) ? main : off;
            if (containsCyrillicLetter(fireChargeStack, 'С')) {
                handled = true;
                float radius = 10.0f;
                Vec3d center = getCircleCenter(event.getTickDelta());
                boolean playersInRadius = checkPlayersInRadius(mc.player, center, radius);
                updateOutlineColor(playersInRadius, event.getTickDelta());
                if (playersInRadius) {
                    renderCircleFill(event, center, radius, 0x3300FF00);
                }
                renderCircleOutline(event, center, radius, currentOutlineColor);
            }
        }

        if (!handled && items.get("Божья Аура") && (isHolding(main, Items.PHANTOM_MEMBRANE) || isHolding(off, Items.PHANTOM_MEMBRANE))) {
            ItemStack membraneStack = isHolding(main, Items.PHANTOM_MEMBRANE) ? main : off;
            if (containsCyrillicLetter(membraneStack, 'У')) {
                handled = true;
                float radius = 2.0f;
                Vec3d center = getCircleCenter(event.getTickDelta());
                boolean playersInRadius = checkPlayersInRadius(mc.player, center, radius);
                boolean friendsInRadius = checkFriendsInRadius(mc.player, center, radius);
                updateOutlineColor(playersInRadius, event.getTickDelta());
                if (friendsInRadius) {
                    renderCircleFill(event, center, radius, 0x3300FF00);
                }
                renderCircleOutline(event, center, radius, currentOutlineColor);
            }
        }

        if (!handled && items.get("Трапка") && (isHolding(main, Items.NETHERITE_SCRAP) || isHolding(off, Items.NETHERITE_SCRAP))) {
            ItemStack scrapStack = isHolding(main, Items.NETHERITE_SCRAP) ? main : off;
            if (containsCyrillicLetter(scrapStack, 'А')) {
                handled = true;
                Vec3d p = getLerpedPlayerPos(event.getTickDelta());
                Vec3d cubeCenter = new Vec3d(
                        p.x,
                        p.y + 0.5 + 1.625,
                        p.z
                );
                boolean playersInRadius = checkPlayersInRadius(mc.player, cubeCenter, 2.5);
                updateOutlineColor(playersInRadius, event.getTickDelta());
                renderCubeOutline(event, cubeCenter, 4.0f, currentOutlineColor);
            }
        }

        if (!handled && items.get("Пласт") && (isHolding(main, Items.DRIED_KELP) || isHolding(off, Items.DRIED_KELP))) {
            ItemStack kelpStack = isHolding(main, Items.DRIED_KELP) ? main : off;
            if (containsCyrillicLetter(kelpStack, 'П')) {
                handled = true;
                PlanePose pose = smoothPlastPose(computePlanePose(event.getTickDelta()), event.getTickDelta());
                boolean playersInRadius = checkPlayersInRadius(mc.player, pose.center, 2.5);
                if (playersInRadius) {
                    renderPlaneFill(event, pose, 0x66FF0000);
                    renderPlaneOutline(event, pose, 0xFFFF0000);
                } else {
                    renderPlaneOutline(event, pose, 0xFF00FF00);
                }
            }
        }

        if (!handled) {
            plastHasSmoothedPose = false;
        }
    }

    private void renderCircleFill(EventRender3D event, Vec3d center, float radius, int fillColor) {
        if (mc.player == null) return;

        BufferAllocator allocator = new BufferAllocator(1 << 16);
        VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(allocator);
        try {
            Matrix4f matrix = event.getMatrixStack().peek().getPositionMatrix();
            Vec3d camera = mc.gameRenderer.getCamera().getPos();
            VertexConsumer buffer = immediate.getBuffer(ITEM_RADIUS_CIRCLE_FILL_LAYER);

            float y = (float) (center.y + mc.player.getHeight());
            float cx = (float) (center.x - camera.x);
            float cy = (float) (y - camera.y);
            float cz = (float) (center.z - camera.z);

            int r = (fillColor >> 16) & 0xFF;
            int g = (fillColor >> 8) & 0xFF;
            int b = fillColor & 0xFF;
            int a = (fillColor >> 24) & 0xFF;

            int stepDeg = 5;
            float prevX = 0.0f;
            float prevZ = 0.0f;
            boolean hasPrev = false;

            for (int deg = 0; deg <= 360; deg += stepDeg) {
                double rad = Math.toRadians(deg);
                float x = cx + (float) (MathHelper.sin((float) rad) * radius);
                float z = cz + (float) (-MathHelper.cos((float) rad) * radius);

                if (!hasPrev) {
                    prevX = x;
                    prevZ = z;
                    hasPrev = true;
                    continue;
                }

                buffer.vertex(matrix, cx, cy, cz).color(r, g, b, a);
                buffer.vertex(matrix, prevX, cy, prevZ).color(r, g, b, a);
                buffer.vertex(matrix, x, cy, z).color(r, g, b, a);

                prevX = x;
                prevZ = z;
            }

            immediate.draw();
        } finally {
            allocator.close();
        }
    }

    private PlanePose smoothPlastPose(PlanePose target, float tickDelta) {
        if (!plastHasSmoothedPose) {
            plastSmoothedCenter = target.center;
            plastSmoothedYawDeg = target.yawDeg;
            plastSmoothedPitchDeg = target.pitchDeg;
            plastHasSmoothedPose = true;
            return target;
        }

        float speed = 12.0f;
        float t = 1.0f - (float) Math.exp(-speed * Math.max(0.0f, tickDelta));

        plastSmoothedCenter = plastSmoothedCenter.lerp(target.center, t);
        plastSmoothedYawDeg = lerpAngleDeg(plastSmoothedYawDeg, target.yawDeg, t);
        plastSmoothedPitchDeg = lerpAngleDeg(plastSmoothedPitchDeg, target.pitchDeg, t);

        return new PlanePose(plastSmoothedCenter, plastSmoothedYawDeg, plastSmoothedPitchDeg);
    }

    private static float lerpAngleDeg(float from, float to, float t) {
        float delta = MathHelper.wrapDegrees(to - from);
        return from + delta * t;
    }

    private void updateOutlineColor(boolean playersInRadius, float tickDelta) {
        if (playersInRadius != lastPlayersInRadius) {
            transitionTimer = 0.0f;
            lastPlayersInRadius = playersInRadius;
        }

        int baseOutline = 0xFFFFFFFF;
        int lightOutline = 0xFF00FF00;
        targetOutlineColor = playersInRadius ? lightOutline : baseOutline;

        float step = TRANSITION_DURATION <= 0.0001f ? 1.0f : (tickDelta / TRANSITION_DURATION);
        transitionTimer = Math.min(transitionTimer + step, 1.0f);
        currentOutlineColor = lerpColor(currentOutlineColor, targetOutlineColor, transitionTimer);
    }

    private static int lerpColor(int startColor, int endColor, float t) {
        int startA = (startColor >> 24) & 0xFF;
        int startR = (startColor >> 16) & 0xFF;
        int startG = (startColor >> 8) & 0xFF;
        int startB = startColor & 0xFF;

        int endA = (endColor >> 24) & 0xFF;
        int endR = (endColor >> 16) & 0xFF;
        int endG = (endColor >> 8) & 0xFF;
        int endB = endColor & 0xFF;

        int a = (int) (startA + (endA - startA) * t);
        int r = (int) (startR + (endR - startR) * t);
        int g = (int) (startG + (endG - startG) * t);
        int b = (int) (startB + (endB - startB) * t);

        return (a << 24) | (r << 16) | (g << 8) | b;
    }

    private static boolean isHolding(ItemStack stack, Item item) {
        return stack != null && !stack.isEmpty() && stack.isOf(item);
    }

    private static boolean containsCyrillicLetter(ItemStack stack, char letter) {
        if (stack == null || stack.isEmpty()) return false;
        String name = stack.getName().getString();
        if (name == null || name.isEmpty()) return false;
        String upper = name.toUpperCase();
        return upper.indexOf(Character.toUpperCase(letter)) >= 0;
    }

    private boolean checkPlayersInRadius(PlayerEntity self, Vec3d centerPos, double radius) {
        if (mc.world == null) return false;
        double r2 = radius * radius;
        for (PlayerEntity p : mc.world.getPlayers()) {
            if (p == null || p == self) continue;
            if (p.squaredDistanceTo(centerPos) <= r2) {
                return true;
            }
        }
        return false;
    }

    private boolean checkFriendsInRadius(PlayerEntity self, Vec3d centerPos, double radius) {
        if (mc.world == null) return false;
        if (Strange.get == null || Strange.get.friendManager == null) return false;

        double r2 = radius * radius;
        for (PlayerEntity p : mc.world.getPlayers()) {
            if (p == null || p == self) continue;
            if (p.squaredDistanceTo(centerPos) > r2) continue;

            String name = p.getName().getString();
            if (name != null && Strange.get.friendManager.isFriend(name)) {
                return true;
            }
        }
        return false;
    }

    private Vec3d getLerpedPlayerPos(float tickDelta) {
        if (mc.player == null) return Vec3d.ZERO;
        double x = mc.player.lastRenderX + (mc.player.getX() - mc.player.lastRenderX) * tickDelta;
        double y = mc.player.lastRenderY + (mc.player.getY() - mc.player.lastRenderY) * tickDelta;
        double z = mc.player.lastRenderZ + (mc.player.getZ() - mc.player.lastRenderZ) * tickDelta;
        return new Vec3d(x, y, z);
    }

    private Vec3d getCircleCenter(float tickDelta) {
        Vec3d pos = getLerpedPlayerPos(tickDelta);
        return pos.add(0.0, -1.4, 0.0);
    }

    private void renderCircleOutline(EventRender3D event, Vec3d center, float radius, int outlineColor) {
        if (mc.player == null) return;

        BufferAllocator allocator = new BufferAllocator(1 << 16);
        VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(allocator);
        try {
            Matrix4f matrix = event.getMatrixStack().peek().getPositionMatrix();
            Vec3d camera = mc.gameRenderer.getCamera().getPos();

            VertexConsumer buffer = immediate.getBuffer(ITEM_RADIUS_LINE_LAYER);

            float y = (float) (center.y + mc.player.getHeight());
            float cx = (float) (center.x - camera.x);
            float cy = (float) (y - camera.y);
            float cz = (float) (center.z - camera.z);

            int r = (outlineColor >> 16) & 0xFF;
            int g = (outlineColor >> 8) & 0xFF;
            int b = outlineColor & 0xFF;
            int a = (outlineColor >> 24) & 0xFF;

            int stepDeg = 5;
            float firstX = 0.0f;
            float firstZ = 0.0f;
            float prevX = 0.0f;
            float prevZ = 0.0f;
            boolean hasPrev = false;

            for (int deg = 0; deg <= 360; deg += stepDeg) {
                double rad = Math.toRadians(deg);
                float x = cx + (float) (MathHelper.sin((float) rad) * radius);
                float z = cz + (float) (-MathHelper.cos((float) rad) * radius);

                if (!hasPrev) {
                    firstX = x;
                    firstZ = z;
                    prevX = x;
                    prevZ = z;
                    hasPrev = true;
                    continue;
                }

                buffer.vertex(matrix, prevX, cy, prevZ).color(r, g, b, a);
                buffer.vertex(matrix, x, cy, z).color(r, g, b, a);

                prevX = x;
                prevZ = z;
            }

            if (hasPrev) {
                buffer.vertex(matrix, prevX, cy, prevZ).color(r, g, b, a);
                buffer.vertex(matrix, firstX, cy, firstZ).color(r, g, b, a);
            }

            immediate.draw();
        } finally {
            allocator.close();
        }
    }

    private void renderPlaneFill(EventRender3D event, PlanePose pose, int fillColor) {
        BufferAllocator allocator = new BufferAllocator(1 << 16);
        VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(allocator);
        try {
            Vec3d camera = mc.gameRenderer.getCamera().getPos();
            VertexConsumer buffer = immediate.getBuffer(ITEM_RADIUS_FILL_LAYER);

            float width = 4.0f;
            float height = 4.0f;
            float thickness = 1.5f;

            float halfW = width / 2.0f;
            float halfH = height / 2.0f;
            float halfT = thickness / 2.0f;

            event.getMatrixStack().push();
            event.getMatrixStack().translate(pose.center.x - camera.x, pose.center.y - camera.y, pose.center.z - camera.z);

            if (Math.abs(pose.pitchDeg) > 0.001f) {
                event.getMatrixStack().multiply(net.minecraft.util.math.RotationAxis.POSITIVE_X.rotationDegrees(pose.pitchDeg));
            }
            if (Math.abs(pose.yawDeg) > 0.001f) {
                event.getMatrixStack().multiply(net.minecraft.util.math.RotationAxis.POSITIVE_Y.rotationDegrees(pose.yawDeg));
            }

            Matrix4f mat = event.getMatrixStack().peek().getPositionMatrix();

            float minX = -halfW;
            float maxX = halfW;
            float minY = -halfH;
            float maxY = halfH;
            float minZ = -halfT;
            float maxZ = halfT;

            drawBoxFaces(buffer, mat, minX, minY, minZ, maxX, maxY, maxZ, fillColor);
            event.getMatrixStack().pop();

            immediate.draw();
        } finally {
            allocator.close();
        }
    }

    private static void drawBoxFaces(VertexConsumer buffer, Matrix4f matrix,
                                     float minX, float minY, float minZ,
                                     float maxX, float maxY, float maxZ,
                                     int color) {
        int r = (color >> 16) & 0xFF;
        int g = (color >> 8) & 0xFF;
        int b = color & 0xFF;
        int a = (color >> 24) & 0xFF;

        buffer.vertex(matrix, minX, minY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, minY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, maxY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, maxY, maxZ).color(r, g, b, a);

        buffer.vertex(matrix, maxX, minY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, minY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, maxY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, maxY, minZ).color(r, g, b, a);

        buffer.vertex(matrix, minX, maxY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, maxY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, maxY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, maxY, minZ).color(r, g, b, a);

        buffer.vertex(matrix, minX, minY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, minY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, minY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, minY, maxZ).color(r, g, b, a);

        buffer.vertex(matrix, minX, minY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, minY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, maxY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, minX, maxY, minZ).color(r, g, b, a);

        buffer.vertex(matrix, maxX, minY, maxZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, minY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, maxY, minZ).color(r, g, b, a);
        buffer.vertex(matrix, maxX, maxY, maxZ).color(r, g, b, a);
    }

    private void renderCubeOutline(EventRender3D event, Vec3d center, float size, int outlineColor) {
        BufferAllocator allocator = new BufferAllocator(1 << 16);
        VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(allocator);
        try {
            Matrix4f matrix = event.getMatrixStack().peek().getPositionMatrix();
            Vec3d camera = mc.gameRenderer.getCamera().getPos();
            VertexConsumer buffer = immediate.getBuffer(ITEM_RADIUS_CUBE_LINE_LAYER);

            float half = size / 2.0f;
            float minX = (float) (center.x - camera.x - half);
            float minY = (float) (center.y - camera.y - half);
            float minZ = (float) (center.z - camera.z - half);
            float maxX = minX + size;
            float maxY = minY + size;
            float maxZ = minZ + size;

            drawBoxEdges(buffer, matrix, minX, minY, minZ, maxX, maxY, maxZ, outlineColor);
            immediate.draw();
        } finally {
            allocator.close();
        }
    }

    private static void drawBoxEdges(VertexConsumer buffer, Matrix4f matrix,
                                     float minX, float minY, float minZ,
                                     float maxX, float maxY, float maxZ,
                                     int color) {
        drawLine(buffer, matrix, minX, minY, minZ, maxX, minY, minZ, color);
        drawLine(buffer, matrix, maxX, minY, minZ, maxX, minY, maxZ, color);
        drawLine(buffer, matrix, maxX, minY, maxZ, minX, minY, maxZ, color);
        drawLine(buffer, matrix, minX, minY, maxZ, minX, minY, minZ, color);

        drawLine(buffer, matrix, minX, maxY, minZ, maxX, maxY, minZ, color);
        drawLine(buffer, matrix, maxX, maxY, minZ, maxX, maxY, maxZ, color);
        drawLine(buffer, matrix, maxX, maxY, maxZ, minX, maxY, maxZ, color);
        drawLine(buffer, matrix, minX, maxY, maxZ, minX, maxY, minZ, color);

        drawLine(buffer, matrix, minX, minY, minZ, minX, maxY, minZ, color);
        drawLine(buffer, matrix, maxX, minY, minZ, maxX, maxY, minZ, color);
        drawLine(buffer, matrix, maxX, minY, maxZ, maxX, maxY, maxZ, color);
        drawLine(buffer, matrix, minX, minY, maxZ, minX, maxY, maxZ, color);
    }

    private static void drawLine(VertexConsumer buffer, Matrix4f matrix,
                                 float x1, float y1, float z1,
                                 float x2, float y2, float z2,
                                 int color) {
        int r = (color >> 16) & 0xFF;
        int g = (color >> 8) & 0xFF;
        int b = color & 0xFF;
        int a = (color >> 24) & 0xFF;
        buffer.vertex(matrix, x1, y1, z1).color(r, g, b, a);
        buffer.vertex(matrix, x2, y2, z2).color(r, g, b, a);
    }

    private record PlanePose(Vec3d center, float yawDeg, float pitchDeg) {
    }

    private PlanePose computePlanePose(float tickDelta) {
        Vec3d playerPos = getLerpedPlayerPos(tickDelta);
        Vec3d start = playerPos.add(0.0, mc.player.getEyeHeight(mc.player.getPose()), 0.0);
        Vec3d lookVec = mc.player.getRotationVec(tickDelta);
        Vec3d end = start.add(lookVec.multiply(4.0));

        BlockHitResult hit = mc.world.raycast(new RaycastContext(
                start,
                end,
                RaycastContext.ShapeType.COLLIDER,
                RaycastContext.FluidHandling.NONE,
                mc.player
        ));

        float pitch = mc.player.getPitch(tickDelta);
        boolean isLookingDown = pitch > 45.0f;
        boolean isLookingUp = pitch < -45.0f;
        boolean isLookingHorizontal = !isLookingDown && !isLookingUp;

        float thickness = 1.5f;
        float halfThickness = thickness / 2.0f;

        Vec3d center;
        float yawDeg;
        float pitchDeg;

        if (hit.getType() == HitResult.Type.BLOCK && hit.getPos().distanceTo(start) <= 4.0) {
            Vec3d hitPos = hit.getPos();
            Direction face = hit.getSide();

            if (isLookingDown) {
                center = new Vec3d(
                        Math.floor(hitPos.x) + 0.5,
                        Math.floor(hitPos.y + 1.0) - 1.8 + halfThickness,
                        Math.floor(hitPos.z) + 0.5
                );
                yawDeg = 0.0f;
                pitchDeg = 90.0f;
            } else if (isLookingUp) {
                center = new Vec3d(
                        Math.floor(hitPos.x) + 0.5,
                        Math.floor(hitPos.y) - halfThickness + 1.6,
                        Math.floor(hitPos.z) + 0.5
                );
                yawDeg = 0.0f;
                pitchDeg = -90.0f;
            } else {
                double offsetX = face.getOffsetX() != 0 ? face.getOffsetX() * halfThickness : 0.0;
                double offsetZ = face.getOffsetZ() != 0 ? face.getOffsetZ() * halfThickness : 0.0;
                center = new Vec3d(
                        Math.floor(hitPos.x) + 0.5 + offsetX,
                        Math.floor(hitPos.y) + 0.5 + 1.6,
                        Math.floor(hitPos.z) + 0.5 + offsetZ
                );

                yawDeg = switch (face) {
                    case NORTH -> 180.0f;
                    case SOUTH -> 0.0f;
                    case WEST -> 90.0f;
                    case EAST -> -90.0f;
                    default -> -mc.player.getYaw(tickDelta);
                };
                pitchDeg = 0.0f;
            }
        } else {
            Vec3d approx = start.add(lookVec.multiply(4.0));
            double y = Math.floor(approx.y) + (isLookingDown ? (-1.8 + halfThickness) : isLookingUp ? (-halfThickness + 1.6) : (0.5 + 1.6));
            center = new Vec3d(Math.floor(approx.x) + 0.5, y, Math.floor(approx.z) + 0.5);
            yawDeg = -mc.player.getYaw(tickDelta);
            pitchDeg = 0.0f;
        }

        if (!isLookingHorizontal) {
            yawDeg = -mc.player.getYaw(tickDelta);
        }

        return new PlanePose(center, yawDeg, pitchDeg);
    }

    private void renderPlaneOutline(EventRender3D event, PlanePose pose, int outlineColor) {
        BufferAllocator allocator = new BufferAllocator(1 << 16);
        VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(allocator);
        try {
            Matrix4f matrix = event.getMatrixStack().peek().getPositionMatrix();
            Vec3d camera = mc.gameRenderer.getCamera().getPos();
            VertexConsumer buffer = immediate.getBuffer(ITEM_RADIUS_LINE_LAYER);

            float width = 4.0f;
            float height = 4.0f;
            float thickness = 1.5f;

            float halfW = width / 2.0f;
            float halfH = height / 2.0f;
            float halfT = thickness / 2.0f;

            event.getMatrixStack().push();
            event.getMatrixStack().translate(pose.center.x - camera.x, pose.center.y - camera.y, pose.center.z - camera.z);

            if (Math.abs(pose.pitchDeg) > 0.001f) {
                event.getMatrixStack().multiply(net.minecraft.util.math.RotationAxis.POSITIVE_X.rotationDegrees(pose.pitchDeg));
            }
            if (Math.abs(pose.yawDeg) > 0.001f) {
                event.getMatrixStack().multiply(net.minecraft.util.math.RotationAxis.POSITIVE_Y.rotationDegrees(pose.yawDeg));
            }

            Matrix4f mat = event.getMatrixStack().peek().getPositionMatrix();

            float minX = -halfW;
            float maxX = halfW;
            float minY = -halfH;
            float maxY = halfH;
            float minZ = -halfT;
            float maxZ = halfT;

            drawBoxEdges(buffer, mat, minX, minY, minZ, maxX, maxY, maxZ, outlineColor);
            event.getMatrixStack().pop();

            immediate.draw();
        } finally {
            allocator.close();
        }
    }

    private static final int LINE_BUFFER_SIZE_BYTES = 1 << 10;

    private static final RenderPipeline ITEM_RADIUS_LINE_PIPELINE = RenderPipelines.register(
            RenderPipeline.builder(RenderPipelines.POSITION_COLOR_SNIPPET)
                    .withLocation(Identifier.of("strange", "pipeline/world/item_radius_lines"))
                    .withVertexFormat(VertexFormats.POSITION_COLOR, VertexFormat.DrawMode.DEBUG_LINES)
                    .withCull(false)
                    .withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST)
                    .withDepthWrite(false)
                    .withBlend(BlendFunction.LIGHTNING)
                    .build()
    );

    private static final RenderLayer ITEM_RADIUS_LINE_LAYER = RenderLayer.of(
            "strange_item_radius_lines",
            LINE_BUFFER_SIZE_BYTES,
            false,
            true,
            ITEM_RADIUS_LINE_PIPELINE,
            RenderLayer.MultiPhaseParameters.builder()
                    .lineWidth(new RenderPhase.LineWidth(OptionalDouble.of(3.0)))
                    .build(false)
    );

    private static final RenderLayer ITEM_RADIUS_CUBE_LINE_LAYER = RenderLayer.of(
            "strange_item_radius_cube_lines",
            LINE_BUFFER_SIZE_BYTES,
            false,
            true,
            ITEM_RADIUS_LINE_PIPELINE,
            RenderLayer.MultiPhaseParameters.builder()
                    .lineWidth(new RenderPhase.LineWidth(OptionalDouble.of(6.0)))
                    .build(false)
    );

    private static final RenderPipeline ITEM_RADIUS_CIRCLE_FILL_PIPELINE = RenderPipelines.register(
            RenderPipeline.builder(RenderPipelines.POSITION_COLOR_SNIPPET)
                    .withLocation(Identifier.of("strange", "pipeline/world/item_radius_circle_fill"))
                    .withVertexFormat(VertexFormats.POSITION_COLOR, VertexFormat.DrawMode.TRIANGLES)
                    .withCull(false)
                    .withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST)
                    .withDepthWrite(false)
                    .withBlend(BlendFunction.LIGHTNING)
                    .build()
    );

    private static final RenderLayer ITEM_RADIUS_CIRCLE_FILL_LAYER = RenderLayer.of(
            "strange_item_radius_circle_fill",
            LINE_BUFFER_SIZE_BYTES,
            false,
            true,
            ITEM_RADIUS_CIRCLE_FILL_PIPELINE,
            RenderLayer.MultiPhaseParameters.builder().build(false)
    );

    private static final RenderPipeline ITEM_RADIUS_FILL_PIPELINE = RenderPipelines.register(
            RenderPipeline.builder(RenderPipelines.POSITION_COLOR_SNIPPET)
                    .withLocation(Identifier.of("strange", "pipeline/world/item_radius_fill"))
                    .withVertexFormat(VertexFormats.POSITION_COLOR, VertexFormat.DrawMode.QUADS)
                    .withCull(false)
                    .withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST)
                    .withDepthWrite(false)
                    .withBlend(BlendFunction.LIGHTNING)
                    .build()
    );

    private static final RenderLayer ITEM_RADIUS_FILL_LAYER = RenderLayer.of(
            "strange_item_radius_fill",
            LINE_BUFFER_SIZE_BYTES,
            false,
            true,
            ITEM_RADIUS_FILL_PIPELINE,
            RenderLayer.MultiPhaseParameters.builder().build(false)
    );
}
Посмотреть вложение 327478Посмотреть вложение 327479Посмотреть вложение 327480Посмотреть вложение 327481Посмотреть вложение 327482
фу 700 строк кода гпт удаляй тему
а в чём отличие от этой темы ? ток что если держишь в руке не явку то не показывает, и всё?https://yougame.biz/threads/357373/
 
а в чём отличие от этой темы ? ток что если держишь в руке не явку то не показывает, и всё?https://yougame.biz/threads/357373/
Давай полностью рассмотрим ваше предложение:

Люди сливают на югейм худы
НО ЗАЧЕМ ИХ СЛИВАЮТ ЕСЛИ УЖЕ В КЛИЕНТЕ ЕСТЬ ХУД??

Для меня это звучит примерно также типо тут он добавил если сахар в руке то не показывает. Также в худах там чел фпс добавил или цвет ректа поменял
 
Давай полностью рассмотрим ваше предложение:

Люди сливают на югейм худы
НО ЗАЧЕМ ИХ СЛИВАЮТ ЕСЛИ УЖЕ В КЛИЕНТЕ ЕСТЬ ХУД??

Для меня это звучит примерно также типо тут он добавил если сахар в руке то не показывает. Также в худах там чел фпс добавил или цвет ректа поменял
что ты блять сморозил вообще?
я спрашиваю в чём отличие этого итем радиуса от той что я силку кидал
 
что ты блять сморозил вообще?
я спрашиваю в чём отличие этого итем радиуса от той что я силку кидал
в том каторый ты дал ссылку если в руки взять обычны сахар или незеритовый скрап то будет отоброжаться а тут только на ностоящих предметах
 
Назад
Сверху Снизу