- Статус
- Оффлайн
- Регистрация
- 28 Авг 2023
- Сообщения
- 135
- Реакции
- 0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
- Выберите загрузчик игры
- Vanilla
- Forge
- Fabric
- NeoForge
- OptiFine
- ForgeOptiFine
- Прочие моды
типа селфкод:
package code.vredux.ui.clienthud.impl;
import com.mojang.blaze3d.matrix.MatrixStack;
import code.vredux.Vredux;
import code.vredux.events.EventRender2D;
import code.vredux.manager.Theme;
import code.vredux.manager.drag.Dragging;
import code.vredux.modules.impl.visual.Hud;
import code.vredux.ui.clienthud.updater.ElementRenderer;
import code.vredux.utils.math.Vector4i;
import code.vredux.utils.render.color.ColorUtility;
import code.vredux.utils.render.engine2d.RenderUtility;
import code.vredux.utils.render.font.Fonts;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ClientBossInfo;
import net.minecraft.world.BossInfo;
import java.util.Collection;
/*
* кароче хз что писать но
* Рич форевер
*/
@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class BossBarHud implements ElementRenderer {
final Dragging dragging;
final Minecraft mc = Minecraft.getInstance();
float width = 250;
float height = 30;
float animatedProgress = 0;
float animatedAlpha = 0;
float animatedWidth = 0;
float animatedHeight = 0;
String lastBossName = "";
float barGlowIntensity = 0;
float pulseAnimation = 0;
float textAnimationScale = 1.0f;
float percentageAnimationAlpha = 0;
long lastUpdateTime = System.currentTimeMillis();
float deltaTime = 0;
@Override
public void render(EventRender2D eventRender2D) {
long currentTime = System.currentTimeMillis();
deltaTime = Math.min((currentTime - lastUpdateTime) / 1000.0f, 0.05f);
lastUpdateTime = currentTime;
Collection<ClientBossInfo> bossInfos = mc.ingameGUI.getBossOverlay().getActiveBossBars();
if (bossInfos.isEmpty()) {
animatedAlpha = smoothLerp(animatedAlpha, 0, 3.0f);
percentageAnimationAlpha = smoothLerp(percentageAnimationAlpha, 0, 4.0f);
barGlowIntensity = smoothLerp(barGlowIntensity, 0, 5.0f);
if (animatedAlpha < 0.01f) {
return;
}
} else {
animatedAlpha = 1.0f;
percentageAnimationAlpha = 1.0f;
barGlowIntensity = smoothLerp(barGlowIntensity, 1, 2.0f);
}
MatrixStack ms = eventRender2D.getMatrixStack();
float posX = dragging.getX();
float posY = dragging.getY();
if (!bossInfos.isEmpty()) {
BossInfo boss = bossInfos.iterator().next();
String bossName = boss.getName().getString();
float progress = boss.getPercent();
animatedProgress = smoothLerp(animatedProgress, progress, 2.5f);
lastBossName = bossName;
pulseAnimation += deltaTime * 3.0f;
textAnimationScale = smoothLerp(textAnimationScale, 1.0f, 8.0f);
Hud hud = Vredux.getInst().getModuleManager().getHud();
if (hud.tHudMode.is("Обычный")) {
renderNormalMode(ms, posX, posY, bossName, animatedProgress);
} else if (hud.tHudMode.is("Большой")) {
renderBigMode(ms, posX, posY, bossName, animatedProgress);
} else {
renderModernMode(ms, posX, posY, bossName, animatedProgress);
}
}
dragging.setWidth(width);
dragging.setHeight(height);
}
private void renderNormalMode(MatrixStack ms, float posX, float posY, String bossName, float progress) {
Fonts.sf.drawText(ms, bossName, posX + 1, posY + 3, ColorUtility.rgba(0, 0, 0, (int)(150 * animatedAlpha)), 9);
Fonts.sf.drawText(ms, bossName, posX, posY + 2, ColorUtility.rgba(getRGB(Theme.textColor)[0], getRGB(Theme.textColor)[1], getRGB(Theme.textColor)[2], (int)(255 * animatedAlpha)), 9);
float barWidth = width;
float barHeight = 8;
float barX = posX;
float barY = posY + 12;
float pulseFactor = (float)(Math.sin(pulseAnimation) * 0.1f + 0.9f);
RenderUtility.drawRoundedRect(barX, barY, barWidth, barHeight, 4,
ColorUtility.rgba(30, 30, 30, (int)(180 * animatedAlpha * pulseFactor)));
Vector4i progressColor = getHealthColorWithAlpha(progress, animatedAlpha);
RenderUtility.drawRoundedRect(barX, barY, barWidth * progress, barHeight, 4, progressColor);
if (progress > 0.1f && barGlowIntensity > 0.1f) {
float glowAlpha = (float)(Math.sin(pulseAnimation * 2) * 0.3f + 0.7f) * barGlowIntensity * animatedAlpha;
RenderUtility.drawRoundedRect(barX, barY + 1, barWidth * progress, barHeight - 2, 3,
ColorUtility.rgba(255, 255, 255, (int)(40 * glowAlpha)));
}
String healthText = Math.round(progress * 100) + "%";
float textWidth = Fonts.sf.getWidth(healthText, 8);
int healthTextColor = getHealthTextColorWithAlpha(progress, animatedAlpha * percentageAnimationAlpha);
ms.push();
ms.scale(textAnimationScale, textAnimationScale, 1.0f);
float scaledX = (posX + barWidth - textWidth - 2) / textAnimationScale;
float scaledY = (posY + 2) / textAnimationScale;
Fonts.sf.drawText(ms, healthText, scaledX, scaledY, healthTextColor, 8);
ms.pop();
}
private void renderBigMode(MatrixStack ms, float posX, float posY, String bossName, float progress) {
width = 300;
height = 35;
Fonts.sf.drawText(ms, bossName, posX + 1, posY + 3, ColorUtility.rgba(0, 0, 0, (int)(150 * animatedAlpha)), 11);
Fonts.sf.drawText(ms, bossName, posX, posY + 2, ColorUtility.rgba(getRGB(Theme.textColor)[0], getRGB(Theme.textColor)[1], getRGB(Theme.textColor)[2], (int)(255 * animatedAlpha)), 11);
float barWidth = width;
float barHeight = 10;
float barX = posX;
float barY = posY + 15;
float borderPulse = (float)(Math.sin(pulseAnimation * 1.5f) * 0.2f + 0.8f);
RenderUtility.drawRoundedRect(barX - 1, barY - 1, barWidth + 2, barHeight + 2, 5,
ColorUtility.rgba(60, 60, 60, (int)(120 * animatedAlpha * borderPulse)));
RenderUtility.drawRoundedRect(barX, barY, barWidth, barHeight, 4,
ColorUtility.rgba(20, 20, 20, (int)(200 * animatedAlpha)));
Vector4i progressColor = getHealthColorWithAlpha(progress, animatedAlpha);
RenderUtility.drawRoundedRect(barX, barY, barWidth * progress, barHeight, 4, progressColor);
if (progress > 0.1f && barGlowIntensity > 0.1f) {
float glowTime = (System.currentTimeMillis() % 2000) / 2000f;
float glowAlpha = (float)(Math.sin(glowTime * Math.PI * 3) * 0.4f + 0.6f) * barGlowIntensity * animatedAlpha;
RenderUtility.drawRoundedRect(barX, barY + 1, barWidth * progress, barHeight - 2, 3,
ColorUtility.rgba(255, 255, 255, (int)(50 * glowAlpha)));
float waveOffset = (glowTime * barWidth * progress) % (barWidth * progress);
if (waveOffset > 0) {
RenderUtility.drawRoundedRect(barX + waveOffset - 10, barY, 20, barHeight, 4,
ColorUtility.rgba(255, 255, 255, (int)(30 * glowAlpha)));
}
}
String healthText = Math.round(progress * 100) + "%";
float textWidth = Fonts.sf.getWidth(healthText, 9);
int healthTextColor = getHealthTextColorWithAlpha(progress, animatedAlpha * percentageAnimationAlpha);
ms.push();
float textPulse = (float)(Math.sin(pulseAnimation * 2) * 0.1f + 1.0f) * textAnimationScale;
ms.scale(textPulse, textPulse, 1.0f);
float scaledX = (posX + (barWidth - textWidth) / 2) / textPulse;
float scaledY = (posY + 27) / textPulse;
Fonts.sf.drawText(ms, healthText, scaledX, scaledY, healthTextColor, 9);
ms.pop();
}
private void renderModernMode(MatrixStack ms, float posX, float posY, String bossName, float progress) {
width = 280;
height = 25;
Fonts.sf.drawText(ms, bossName, posX, posY + 2, ColorUtility.rgba(getRGB(Theme.textColor)[0], getRGB(Theme.textColor)[1], getRGB(Theme.textColor)[2], (int)(255 * animatedAlpha)), 10);
float barWidth = width;
float barHeight = 6;
float barX = posX;
float barY = posY + 12;
float backgroundPulse = (float)(Math.sin(pulseAnimation * 0.5f) * 0.15f + 0.85f);
RenderUtility.drawRoundedRect(barX, barY, barWidth, barHeight, 3,
ColorUtility.rgba(40, 40, 40, (int)(160 * animatedAlpha * backgroundPulse)));
Vector4i modernColor = new Vector4i(
ColorUtility.rgba(getRGB(Theme.mainRectColor)[0], getRGB(Theme.mainRectColor)[1], getRGB(Theme.mainRectColor)[2], (int)(255 * animatedAlpha)),
ColorUtility.rgba(getRGB(Theme.mainRectColor)[0], getRGB(Theme.mainRectColor)[1], getRGB(Theme.mainRectColor)[2], (int)(255 * animatedAlpha)),
ColorUtility.rgba(getRGB(Theme.textColor)[0], getRGB(Theme.textColor)[1], getRGB(Theme.textColor)[2], (int)(255 * animatedAlpha)),
ColorUtility.rgba(getRGB(Theme.textColor)[0], getRGB(Theme.textColor)[1], getRGB(Theme.textColor)[2], (int)(255 * animatedAlpha))
);
RenderUtility.drawRoundedRect(barX, barY, barWidth * progress, barHeight, 3, modernColor);
if (progress > 0.05f && barGlowIntensity > 0.1f) {
float glowTime = (System.currentTimeMillis() % 1200) / 1200f;
float glowAlpha = (float)(Math.sin(glowTime * Math.PI * 4) * 0.5f + 0.5f) * barGlowIntensity * animatedAlpha;
float glowX = barX + (barWidth * progress) - 4;
RenderUtility.drawRoundedRect(glowX, barY - 1, 4, barHeight + 2, 2,
ColorUtility.rgba(255, 255, 255, (int)(150 * glowAlpha)));
RenderUtility.drawRoundedRect(glowX - 8, barY, 8, barHeight, 2,
ColorUtility.rgba(255, 255, 255, (int)(50 * glowAlpha)));
}
String healthText = Math.round(progress * 100) + "%";
float textWidth = Fonts.sf.getWidth(healthText, 8);
int healthTextColor = getHealthTextColorWithAlpha(progress, animatedAlpha * percentageAnimationAlpha);
ms.push();
float textPulse = (float)(Math.sin(pulseAnimation * 1.5f) * 0.05f + 0.95f) * textAnimationScale;
ms.scale(textPulse, textPulse, 1.0f);
float scaledX = (posX + barWidth - textWidth) / textPulse;
float scaledY = (posY + 20) / textPulse;
Fonts.sf.drawText(ms, healthText, scaledX, scaledY, healthTextColor, 8);
ms.pop();
}
private Vector4i getHealthColor(float progress) {
if (progress > 0.75f) {
return new Vector4i(
ColorUtility.rgba(85, 255, 85, 255),
ColorUtility.rgba(50, 255, 50, 255),
ColorUtility.rgba(40, 200, 40, 255),
ColorUtility.rgba(30, 150, 30, 255)
);
} else if (progress > 0.5f) {
return new Vector4i(
ColorUtility.rgba(255, 255, 85, 255),
ColorUtility.rgba(255, 255, 50, 255),
ColorUtility.rgba(200, 200, 40, 255),
ColorUtility.rgba(150, 150, 30, 255)
);
} else if (progress > 0.25f) {
return new Vector4i(
ColorUtility.rgba(255, 165, 50, 255),
ColorUtility.rgba(255, 140, 40, 255),
ColorUtility.rgba(200, 120, 30, 255),
ColorUtility.rgba(150, 100, 20, 255)
);
} else {
return new Vector4i(
ColorUtility.rgba(255, 85, 85, 255),
ColorUtility.rgba(255, 50, 50, 255),
ColorUtility.rgba(200, 40, 40, 255),
ColorUtility.rgba(150, 30, 30, 255)
);
}
}
private Vector4i getHealthColorWithAlpha(float progress, float alpha) {
int alphaInt = (int)(255 * alpha);
if (progress > 0.75f) {
return new Vector4i(
ColorUtility.rgba(85, 255, 85, alphaInt),
ColorUtility.rgba(50, 255, 50, alphaInt),
ColorUtility.rgba(40, 200, 40, alphaInt),
ColorUtility.rgba(30, 150, 30, alphaInt)
);
} else if (progress > 0.5f) {
return new Vector4i(
ColorUtility.rgba(255, 255, 85, alphaInt),
ColorUtility.rgba(255, 255, 50, alphaInt),
ColorUtility.rgba(200, 200, 40, alphaInt),
ColorUtility.rgba(150, 150, 30, alphaInt)
);
} else if (progress > 0.25f) {
return new Vector4i(
ColorUtility.rgba(255, 165, 50, alphaInt),
ColorUtility.rgba(255, 140, 40, alphaInt),
ColorUtility.rgba(200, 120, 30, alphaInt),
ColorUtility.rgba(150, 100, 20, alphaInt)
);
} else {
return new Vector4i(
ColorUtility.rgba(255, 85, 85, alphaInt),
ColorUtility.rgba(255, 50, 50, alphaInt),
ColorUtility.rgba(200, 40, 40, alphaInt),
ColorUtility.rgba(150, 30, 30, alphaInt)
);
}
}
private int getHealthTextColorWithAlpha(float progress, float alpha) {
int alphaInt = (int)(255 * alpha);
if (progress > 0.75f) {
return ColorUtility.rgba(85, 255, 85, alphaInt);
} else if (progress > 0.5f) {
return ColorUtility.rgba(255, 255, 85, alphaInt);
} else if (progress > 0.25f) {
return ColorUtility.rgba(255, 165, 50, alphaInt);
} else {
return ColorUtility.rgba(255, 85, 85, alphaInt);
}
}
private int getHealthTextColor(float progress) {
if (progress > 0.75f) {
return ColorUtility.rgba(85, 255, 85, 255);
} else if (progress > 0.5f) {
return ColorUtility.rgba(255, 255, 85, 255);
} else if (progress > 0.25f) {
return ColorUtility.rgba(255, 165, 50, 255);
} else {
return ColorUtility.rgba(255, 85, 85, 255);
}
}
private int[] getRGB(int color) {
return new int[]{(color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF};
}
private float smoothLerp(float start, float end, float speed) {
float factor = 1.0f - (float)Math.exp(-speed * deltaTime);
return start + factor * (end - start);
}
private float lerp(float start, float end, float factor) {
return start + factor * (end - start);
}
}
Написан на базе вредукса как можна понять по импортам ну ок да (первая работа каторая фигня я думаю)
переделал дизайн =D
(во вложение старый СС)
Вложения
Последнее редактирование: