Начинающий
- Статус
- Оффлайн
- Регистрация
- 16 Окт 2024
- Сообщения
- 11
- Реакции
- 0
- Выберите загрузчик игры
- Прочие моды
Сделал минималистичную вотермарку под експу, моя первая работа так что в будущем будет лучше
Java:
package im.expensive.ui.display.impl;
import com.mojang.blaze3d.matrix.MatrixStack;
import im.expensive.events.EventDisplay;
import im.expensive.ui.display.ElementRenderer;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.font.Fonts;
import net.minecraft.util.ResourceLocation;
public class WatermarkRenderer implements ElementRenderer {
private static final ResourceLocation LOGO = new ResourceLocation("expensive/images/hud/logo.png");
private static final float WIDTH = 140f;
private static final float HEIGHT = 18f;
private static final float PADDING = 6f;
private static final float CORNER_RADIUS = 5f;
private long startTime = System.currentTimeMillis();
@Override
public void render(EventDisplay event) {
MatrixStack matrix = event.getMatrixStack();
float x = PADDING, y = PADDING;
renderBackground(x, y);
renderLogo(x, y);
renderClientText(x, y);
renderFps(x, y);
}
private void renderBackground(float x, float y) {
DisplayUtils.drawRoundedRect(x, y, WIDTH, HEIGHT, CORNER_RADIUS,
ColorUtils.rgba(0, 0, 0, 184));
}
private void renderLogo(float x, float y) {
float logoSize = 14f;
float logoX = x + 4f;
float logoY = y + (HEIGHT - logoSize) / 2;
DisplayUtils.drawImage(LOGO, logoX, logoY, logoSize, logoSize, ColorUtils.rgb(255, 255, 255));
}
private void renderClientText(float x, float y) {
String text = "PastaClient";
float textWidth = Fonts.sfui.getWidth(text, 9);
float textX = x + 22f;
float textY = y + (HEIGHT - 10) / 2 + 1f;
int color = getRainbowColor();
Fonts.sfui.drawText(new MatrixStack(), text, textX, textY, color, 9);
}
private void renderFps(float x, float y) {
int fps = net.minecraft.client.Minecraft.getInstance().debugFPS;
String fpsText = fps + " fps";
float fpsWidth = Fonts.sfui.getWidth(fpsText, 7);
float fpsX = x + WIDTH - fpsWidth - 10f;
float fpsY = y + (HEIGHT - 8) / 2 + 1f;
Fonts.sfui.drawText(new MatrixStack(), fpsText, fpsX, fpsY,
ColorUtils.rgb(255, 255, 255), 7);
}
private int getRainbowColor() {
long time = System.currentTimeMillis() - startTime;
float hue = (time % 5000) / 5000f;
return java.awt.Color.HSBtoRGB(hue, 0.8f, 1f);
}
}