• Ищем качественного (не новичок) разработчиков Xenforo для этого форума! В идеале, чтобы ты был фулл стек программистом. Если у тебя есть что показать, то свяжись с нами по контактным данным: https://t.me/DREDD

Target hud default

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
23 Июн 2023
Сообщения
140
Реакции
0
1737457889613.png

Java:
Expand Collapse Copy
private final Dragging targetInfo = NovaCore.createDraggable(this, "TargetInfo", 20, 90);
    private final Animation targetInfoAnimation = new DecelerateAnimation(300, 1);
    private PlayerEntity target = null;
    private float hpAnim = 0;

    //wake up, filthy!
    private void onRenderTargetInfo(MatrixStack matrixStack) {
        float x = targetInfo.getX();
        float y = targetInfo.getY();
        targetInfo.setX(x);
        targetInfo.setY(y);
        target = getTarget(target);
        if (target == null) return;

        int firstColorStyle =
                ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(0), 255),
                secondColorStyle = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(0),255),
                firstColorA = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(90),255),
                secondColorA = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(90),255);

        float width = 100;
        float height = 38;

        int hp = (int) (ClientUtils.isConnectedToServer("reallyworld") ? getHealthFromScoreboard(target)[0] : target.getHealth());
        float maxHp = target.getMaxHealth();
        float healthAnimation = MathHelper.clamp(hp / maxHp, 0, 1);
        hpAnim = ScaleUtils.lerp(hpAnim, healthAnimation, 10);
        ScaleUtils.scaleStart(x + (width / 2f), y + (height / 2f), targetInfoAnimation.getOutput());
        RenderUtils.Render2D.drawRound(x, y, width, height, 4, ColorUtils.rgba(20, 20, 20, 200));
        RenderUtils.Render2D.drawRoundFace(x + 5, y +5, 28, 28,2, 1, (AbstractClientPlayerEntity) target);
        RenderUtils.Render2D.drawGradientRound(x + 38, y + 18, (width - 43), 9, new Vector4f(3, 3, 3, 3), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230));
        RenderUtils.Render2D.drawGradientRound(x + 38, y + 18, (width - 43) * hpAnim, 9, new Vector4f(3, 3, 3, 3), firstColorStyle, secondColorStyle, firstColorA, secondColorA);
        Fonts.sfMedium[16].drawScissorString(matrixStack,target.getName().getString(), x + 38, y + 10,  -1, 24);
        Fonts.sfMedium[16].drawString(matrixStack, " - "+ hp + "hp", x + 68.5f, y + 10, -1);
        ScaleUtils.scaleEnd();
        targetInfo.setWidth(width);
        targetInfo.setHeight(height);
    }
    //я будто зомби ща
 
Посмотреть вложение 296565
Java:
Expand Collapse Copy
private final Dragging targetInfo = NovaCore.createDraggable(this, "TargetInfo", 20, 90);
    private final Animation targetInfoAnimation = new DecelerateAnimation(300, 1);
    private PlayerEntity target = null;
    private float hpAnim = 0;

    //wake up, filthy!
    private void onRenderTargetInfo(MatrixStack matrixStack) {
        float x = targetInfo.getX();
        float y = targetInfo.getY();
        targetInfo.setX(x);
        targetInfo.setY(y);
        target = getTarget(target);
        if (target == null) return;

        int firstColorStyle =
                ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(0), 255),
                secondColorStyle = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(0),255),
                firstColorA = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(90),255),
                secondColorA = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(90),255);

        float width = 100;
        float height = 38;

        int hp = (int) (ClientUtils.isConnectedToServer("reallyworld") ? getHealthFromScoreboard(target)[0] : target.getHealth());
        float maxHp = target.getMaxHealth();
        float healthAnimation = MathHelper.clamp(hp / maxHp, 0, 1);
        hpAnim = ScaleUtils.lerp(hpAnim, healthAnimation, 10);
        ScaleUtils.scaleStart(x + (width / 2f), y + (height / 2f), targetInfoAnimation.getOutput());
        RenderUtils.Render2D.drawRound(x, y, width, height, 4, ColorUtils.rgba(20, 20, 20, 200));
        RenderUtils.Render2D.drawRoundFace(x + 5, y +5, 28, 28,2, 1, (AbstractClientPlayerEntity) target);
        RenderUtils.Render2D.drawGradientRound(x + 38, y + 18, (width - 43), 9, new Vector4f(3, 3, 3, 3), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230));
        RenderUtils.Render2D.drawGradientRound(x + 38, y + 18, (width - 43) * hpAnim, 9, new Vector4f(3, 3, 3, 3), firstColorStyle, secondColorStyle, firstColorA, secondColorA);
        Fonts.sfMedium[16].drawScissorString(matrixStack,target.getName().getString(), x + 38, y + 10,  -1, 24);
        Fonts.sfMedium[16].drawString(matrixStack, " - "+ hp + "hp", x + 68.5f, y + 10, -1);
        ScaleUtils.scaleEnd();
        targetInfo.setWidth(width);
        targetInfo.setHeight(height);
    }
    //я будто зомби ща
норм
 
Извиняюсь, насрал говна кода по цветам, уберите setAlpha(), просто до этого использовал анимацию затухание или как это объяснить я хз.
 
Посмотреть вложение 296565
Java:
Expand Collapse Copy
private final Dragging targetInfo = NovaCore.createDraggable(this, "TargetInfo", 20, 90);
    private final Animation targetInfoAnimation = new DecelerateAnimation(300, 1);
    private PlayerEntity target = null;
    private float hpAnim = 0;

    //wake up, filthy!
    private void onRenderTargetInfo(MatrixStack matrixStack) {
        float x = targetInfo.getX();
        float y = targetInfo.getY();
        targetInfo.setX(x);
        targetInfo.setY(y);
        target = getTarget(target);
        if (target == null) return;

        int firstColorStyle =
                ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(0), 255),
                secondColorStyle = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(0),255),
                firstColorA = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(90),255),
                secondColorA = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(90),255);

        float width = 100;
        float height = 38;

        int hp = (int) (ClientUtils.isConnectedToServer("reallyworld") ? getHealthFromScoreboard(target)[0] : target.getHealth());
        float maxHp = target.getMaxHealth();
        float healthAnimation = MathHelper.clamp(hp / maxHp, 0, 1);
        hpAnim = ScaleUtils.lerp(hpAnim, healthAnimation, 10);
        ScaleUtils.scaleStart(x + (width / 2f), y + (height / 2f), targetInfoAnimation.getOutput());
        RenderUtils.Render2D.drawRound(x, y, width, height, 4, ColorUtils.rgba(20, 20, 20, 200));
        RenderUtils.Render2D.drawRoundFace(x + 5, y +5, 28, 28,2, 1, (AbstractClientPlayerEntity) target);
        RenderUtils.Render2D.drawGradientRound(x + 38, y + 18, (width - 43), 9, new Vector4f(3, 3, 3, 3), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230));
        RenderUtils.Render2D.drawGradientRound(x + 38, y + 18, (width - 43) * hpAnim, 9, new Vector4f(3, 3, 3, 3), firstColorStyle, secondColorStyle, firstColorA, secondColorA);
        Fonts.sfMedium[16].drawScissorString(matrixStack,target.getName().getString(), x + 38, y + 10,  -1, 24);
        Fonts.sfMedium[16].drawString(matrixStack, " - "+ hp + "hp", x + 68.5f, y + 10, -1);
        ScaleUtils.scaleEnd();
        targetInfo.setWidth(width);
        targetInfo.setHeight(height);
    }
    //я будто зомби ща
по теме: выглядит неплохо
по коду: следи за отступами, для другого юзера код будет более читабельным, и у тебя будет получаться красивый и приятный код (см. ниже)

Java:
Expand Collapse Copy
    float x = targetInfo.getX();
    float y = targetInfo.getY();

    targetInfo.setX(x);
    targetInfo.setY(y);

    target = getTarget(target);

    if (target == null)
        return;

    int firstColorStyle =
        ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(0), 255),
        secondColorStyle = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(0), 255),
        firstColorA = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(90), 255),
        secondColorA = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(90), 255);
    int hp = (int)(ClientUtils.isConnectedToServer("reallyworld") ? getHealthFromScoreboard(target)[0] : target.getHealth());
  
    float maxHp = target.getMaxHealth();
    float healthAnimation = MathHelper.clamp(hp / maxHp, 0, 1);
 
    float width = 100;
    float height = 38;
 
    hpAnim = ScaleUtils.lerp(hpAnim, healthAnimation, 10);
    ScaleUtils.scaleStart(x + (width / 2f), y + (height / 2f), targetInfoAnimation.getOutput());

    RenderUtils.Render2D.drawRound(x, y, width, height, 4, ColorUtils.rgba(20, 20, 20, 200));
    RenderUtils.Render2D.drawRoundFace(x + 5, y + 5, 28, 28, 2, 1, (AbstractClientPlayerEntity)target);
    RenderUtils.Render2D.drawGradientRound(x + 38, y + 18, (width - 43), 9, new Vector4f(3, 3, 3, 3), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230));
    RenderUtils.Render2D.drawGradientRound(x + 38, y + 18, (width - 43) * hpAnim, 9, new Vector4f(3, 3, 3, 3), firstColorStyle, secondColorStyle, firstColorA, secondColorA);
  
    Fonts.sfMedium[16].drawScissorString(matrixStack, target.getName().getString(), x + 38, y + 10, -1, 24);
    Fonts.sfMedium[16].drawString(matrixStack, " - " + hp + "hp", x + 68.5f, y + 10, -1);
  
    ScaleUtils.scaleEnd();

    targetInfo.setWidth(width);
    targetInfo.setHeight(height);
 
Последнее редактирование:
по теме: выглядит неплохо
по коду: следи за отступами, для другого юзера код будет более читабельным, и у тебя будет получаться красивый и приятный код (см. ниже)

Java:
Expand Collapse Copy
    float x = targetInfo.getX();
    float y = targetInfo.getY();

    targetInfo.setX(x);
    targetInfo.setY(y);

    target = getTarget(target);

    if (target == null)
        return;

    int firstColorStyle =
        ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(0), 255),
        secondColorStyle = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(0), 255),
        firstColorA = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(90), 255),
        secondColorA = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(90), 255);
    int hp = (int)(ClientUtils.isConnectedToServer("reallyworld") ? getHealthFromScoreboard(target)[0] : target.getHealth());
 
    float maxHp = target.getMaxHealth();
    float healthAnimation = MathHelper.clamp(hp / maxHp, 0, 1);

    float width = 100;
    float height = 38;

    hpAnim = ScaleUtils.lerp(hpAnim, healthAnimation, 10);
    ScaleUtils.scaleStart(x + (width / 2f), y + (height / 2f), targetInfoAnimation.getOutput());

    RenderUtils.Render2D.drawRound(x, y, width, height, 4, ColorUtils.rgba(20, 20, 20, 200));
    RenderUtils.Render2D.drawRoundFace(x + 5, y + 5, 28, 28, 2, 1, (AbstractClientPlayerEntity)target);
    RenderUtils.Render2D.drawGradientRound(x + 38, y + 18, (width - 43), 9, new Vector4f(3, 3, 3, 3), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230));
    RenderUtils.Render2D.drawGradientRound(x + 38, y + 18, (width - 43) * hpAnim, 9, new Vector4f(3, 3, 3, 3), firstColorStyle, secondColorStyle, firstColorA, secondColorA);
 
    Fonts.sfMedium[16].drawScissorString(matrixStack, target.getName().getString(), x + 38, y + 10, -1, 24);
    Fonts.sfMedium[16].drawString(matrixStack, " - " + hp + "hp", x + 68.5f, y + 10, -1);
 
    ScaleUtils.scaleEnd();

    targetInfo.setWidth(width);
    targetInfo.setHeight(height);
можно ScaleUtils?
 
Я ща не дома. Это просто скейл по Gl
по теме: выглядит неплохо
по коду: следи за отступами, для другого юзера код будет более читабельным, и у тебя будет получаться красивый и приятный код (см. ниже)

Java:
Expand Collapse Copy
    float x = targetInfo.getX();
    float y = targetInfo.getY();

    targetInfo.setX(x);
    targetInfo.setY(y);

    target = getTarget(target);

    if (target == null)
        return;

    int firstColorStyle =
        ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(0), 255),
        secondColorStyle = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(0), 255),
        firstColorA = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(90), 255),
        secondColorA = ColorUtils.setAlpha(ColorUtils.getStaticColorStyle(90), 255);
    int hp = (int)(ClientUtils.isConnectedToServer("reallyworld") ? getHealthFromScoreboard(target)[0] : target.getHealth());
 
    float maxHp = target.getMaxHealth();
    float healthAnimation = MathHelper.clamp(hp / maxHp, 0, 1);

    float width = 100;
    float height = 38;

    hpAnim = ScaleUtils.lerp(hpAnim, healthAnimation, 10);
    ScaleUtils.scaleStart(x + (width / 2f), y + (height / 2f), targetInfoAnimation.getOutput());

    RenderUtils.Render2D.drawRound(x, y, width, height, 4, ColorUtils.rgba(20, 20, 20, 200));
    RenderUtils.Render2D.drawRoundFace(x + 5, y + 5, 28, 28, 2, 1, (AbstractClientPlayerEntity)target);
    RenderUtils.Render2D.drawGradientRound(x + 38, y + 18, (width - 43), 9, new Vector4f(3, 3, 3, 3), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230), ColorUtils.rgba(10, 10, 10, 230));
    RenderUtils.Render2D.drawGradientRound(x + 38, y + 18, (width - 43) * hpAnim, 9, new Vector4f(3, 3, 3, 3), firstColorStyle, secondColorStyle, firstColorA, secondColorA);
 
    Fonts.sfMedium[16].drawScissorString(matrixStack, target.getName().getString(), x + 38, y + 10, -1, 24);
    Fonts.sfMedium[16].drawString(matrixStack, " - " + hp + "hp", x + 68.5f, y + 10, -1);
 
    ScaleUtils.scaleEnd();

    targetInfo.setWidth(width);
    targetInfo.setHeight(height);
Похуй на красоту.?
 
Вау! У тебя неплохо получилось сделать говнище! Жду перезалив <3
 
Назад
Сверху Снизу