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

Визуальная часть MainScreen 3.1

моя первая тема да знаю такое себе но кто хочет тот доработает и сделает норм (шрифты починил точнее цифры)
фон-https://workupload.com/file/URaV8FXLLWm
шрифт(не баганный)-https://workupload.com/archive/WxfrhJHxt7
ss(new)-Посмотреть вложение 320971
MainScreen:
Expand Collapse Copy
package im.expensive.ui.mainmenu;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import im.expensive.Expensive;
import im.expensive.utils.client.ClientUtil;
import im.expensive.utils.client.IMinecraft;
import im.expensive.utils.client.Vec2i;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.math.StopWatch;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.KawaseBlur;
import im.expensive.utils.render.Stencil;
import im.expensive.utils.render.font.Fonts;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.MultiplayerScreen;
import net.minecraft.client.gui.screen.OptionsScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.WorldSelectionScreen;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;

import java.net.URI;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ThreadLocalRandom;


public class MainScreen extends Screen implements IMinecraft {
public MainScreen() {
super(ITextComponent.getTextComponentOrEmpty(""));

    }

private final ResourceLocation backmenu = new ResourceLocation("expensive/images/mainscreen/bg_glow.png");
// private final ResourceLocation logo = new ResourceLocation("expensive/images/logo.png");

    private final List<Button> buttons = new ArrayList<>();
private Button altButton;

@Override
    public void init(Minecraft minecraft, int width, int height) {
 super.init(minecraft, width, height);

float widthButton = 100;
float heightButton = 25;
float spacing = 5;

// Create buttons list temporarily to calculate positions
        buttons.clear();

// Define actions
        Runnable singleplayerAction = () -> mc.displayGuiScreen(new WorldSelectionScreen(this));
Runnable multiplayerAction = () -> mc.displayGuiScreen(new MultiplayerScreen(this));
Runnable optionsAction = () -> mc.displayGuiScreen(new OptionsScreen(this, mc.gameSettings));
Runnable changelogAction = () -> mc.displayGuiScreen(new ChangelogScreen());
        Runnable telegramAction = () -> {
 try {
Util.getOSType().openURI(new URI("https://t.me/ваштгк"));
} catch (Exception e) {
                e.printStackTrace();
            }
        };
Runnable exitAction = mc::shutdownMinecraftApplet;
Runnable altAction = () -> mc.displayGuiScreen(Expensive.getInstance().getAltScreen());

// Add buttons to list to iterate for positioning
        // We'll initialize them with dummy coords first
        buttons.add(new Button(0, 0, widthButton, heightButton, "singleplayer", singleplayerAction));
buttons.add(new Button(0, 0, widthButton, heightButton, "multiplayer", multiplayerAction));
buttons.add(new Button(0, 0, widthButton, heightButton, "options", optionsAction));
buttons.add(new Button(0, 0, widthButton, heightButton, "changelog", changelogAction));
buttons.add(new Button(0, 0, widthButton, heightButton, "telegram", telegramAction));
buttons.add(new Button(0, 0, widthButton, heightButton, "exit", exitAction));

// Alt Manager button also at bottom
        altButton = new Button(0, 0, widthButton, heightButton, "alt", altAction);

// Calculate total width
        // 6 main buttons + 1 alt button
        int totalButtons = buttons.size() + 1;
float totalWidth = totalButtons * widthButton + (totalButtons - 1) * spacing;

float startX = (ClientUtil.calc(width) - totalWidth) / 2;
float y = ClientUtil.calc(height) - 50; // Position from bottom

        // Update positions
        for (int i = 0; i < buttons.size(); i++) {
Button b = buttons.get(i);
// Create new button with correct coords (Button class fields are final)
            buttons.set(i, new Button(startX + i * (widthButton + spacing), y, widthButton, heightButton, b.text, b.action));
        }

// Set Alt Button position (last one)
        altButton = new Button(startX + buttons.size() * (widthButton + spacing), y, widthButton, heightButton, "alt", altAction);
    }

private static final CopyOnWriteArrayList<Particle> particles = new CopyOnWriteArrayList<>();

private final StopWatch stopWatch = new StopWatch();
static boolean start = false;

@Override
    public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
 return super.mouseScrolled(mouseX, mouseY, delta);
    }

@Override
    public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
 super.render(matrixStack, mouseX, mouseY, partialTicks);
if (stopWatch.isReached(100)) {
particles.add(new Particle());
 stopWatch.reset();
        }
MainWindow mainWindow = mc.getMainWindow();
int windowWidth = ClientUtil.calc(mainWindow.getScaledWidth());
int windowHeight = ClientUtil.calc(mainWindow.getScaledHeight());

int logoWidth = 1920 / 2;
int logoHeight = 1080 / 2;

// Расчет координат для рисования логотипа по центру
        int xLogo = (windowWidth - logoWidth) / 2;
int yLogo = (windowHeight - logoHeight) / 2 + 50;
boolean small = mainWindow.getWidth() < 900 && mainWindow.getHeight() < 900;
 if (small) {
yLogo += 50;
        }
// Рисование логотипа по центру
        DisplayUtils.drawImage(backmenu, 0, 0, width, height, -1);

// Draw Time and Date in Center
        LocalDateTime now = LocalDateTime.now();
String timeText = now.format(DateTimeFormatter.ofPattern("HH:mm:ss"));
String dateText = now.format(DateTimeFormatter.ofPattern("dd.MM.yyyy"));

float centerX = width / 2f;
float centerY = height / 2f;

Fonts.sf.drawCenteredText(matrixStack, timeText, centerX, centerY - 20, -1, 40f); // Large time
        Fonts.sf.drawCenteredText(matrixStack, dateText, centerX, centerY + 20, -1, 20f); // Date below

        mc.gameRenderer.setupOverlayRendering(2);
// DisplayUtils.drawImage(logo, xLogo, yLogo, logoWidth, logoHeight, -1);

        KawaseBlur.blur.updateBlur(3, 4);
com.mojang.blaze3d.systems.RenderSystem.enableBlend();
com.mojang.blaze3d.systems.RenderSystem.defaultBlendFunc();
com.mojang.blaze3d.platform.GlStateManager.enableAlphaTest();
com.mojang.blaze3d.systems.RenderSystem.disableDepthTest();
com.mojang.blaze3d.platform.GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f);
        drawButtons(matrixStack, mouseX, mouseY, partialTicks);
 altButton.render(matrixStack, mouseX, mouseY, partialTicks);
com.mojang.blaze3d.systems.RenderSystem.enableDepthTest();

GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f);
GlStateManager.bindTexture(0);
GlStateManager.enableTexture();
GlStateManager.enableAlphaTest();
GlStateManager.colorMask(true, true, true, true);
GlStateManager.depthMask(true);

mc.gameRenderer.setupOverlayRendering();

    }

@Override
    public boolean charTyped(char codePoint, int modifiers) {
 return super.charTyped(codePoint, modifiers);
    }

@Override
    public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
 return false;
    }

@Override
    public boolean mouseClicked(double mouseX, double mouseY, int button) {
Vec2i fixed = ClientUtil.getMouse((int) mouseX, (int) mouseY);
buttons.forEach(b -> b.click(fixed.getX(), fixed.getY(), button));
 altButton.click(fixed.getX(), fixed.getY(), button);
 return super.mouseClicked(mouseX, mouseY, button);
    }

private void drawButtons(MatrixStack stack, int mX, int mY, float pt) {

buttons.forEach(b -> b.render(stack, mX, mY, pt));
    }


 private class Particle {

private final float x;
private float y;
private float size;

public Particle() {
x = ThreadLocalRandom.current().nextInt(0, mc.getMainWindow().getScaledWidth());
y = 0;
size = 0;
        }

public void update() {
y += 1f;
        }

public void render(MatrixStack stack) {
            update();
size += 0.1f;
GlStateManager.pushMatrix();
GlStateManager.translated((x + Math.sin((System.nanoTime() / 1000000000f)) * 5), y, 0);
GlStateManager.rotatef(size * 20, 0, 0, 1);
GlStateManager.translated(-(x + Math.sin((System.nanoTime() / 1000000000f)) * 5), -y, 0);
float multi = 1 - MathHelper.clamp((y / mc.getMainWindow().getScaledHeight()), 0, 1);
Fonts.damage.drawText(stack, "A", (float) (x + Math.sin((System.nanoTime() / 1000000000f)) * 5), y, -1, MathHelper.clamp(size * multi, 0, 9));
GlStateManager.popMatrix();
if (y >= mc.getMainWindow().getScaledHeight()) {
particles.remove(this);
            }
        }

    }

@AllArgsConstructor
    private class Button {
@Getter
        private final float x, y, width, height;
private String text;
private Runnable action;

public void render(MatrixStack stack, int mouseX, int mouseY, float pt) {
com.mojang.blaze3d.systems.RenderSystem.enableBlend();
com.mojang.blaze3d.systems.RenderSystem.defaultBlendFunc();

boolean hovered = MathUtil.isHovered(mouseX, mouseY, x, y, width, height);

// Draw blur background
            Stencil.initStencilToWrite();
DisplayUtils.drawRoundedRect(x, y + 2, width, height, 6f, -1);
Stencil.readStencilBuffer(1);
KawaseBlur.blur.BLURRED.draw();
Stencil.uninitStencilBuffer();

// Reset GL state after stencil/blur
            GlStateManager.bindTexture(0);
GlStateManager.enableTexture();
GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f);

// Полупрозрачный темный фон
            int bgColor = hovered ? ColorUtils.rgba(60, 60, 60, 180) : ColorUtils.rgba(30, 30, 30, 160);
DisplayUtils.drawRoundedRect(x, y + 2, width, height, 6f, bgColor);

// Reset state before text
            GlStateManager.bindTexture(0);
GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f);
com.mojang.blaze3d.systems.RenderSystem.enableBlend();
com.mojang.blaze3d.systems.RenderSystem.defaultBlendFunc();

int textColor = hovered ? ColorUtils.rgb(255, 255, 255) : ColorUtils.rgba(255, 255, 255, 200);
Fonts.montserrat.drawCenteredText(stack, text, x + width / 2f, y + height / 2f - 5.5f + 2, textColor, 10f);
        }

public void click(int mouseX, int mouseY, int button) {
if (MathUtil.isHovered(mouseX, mouseY, x, y, width, height)) {
 action.run();
            }
        }

    }


}
если че делал ии и на лишнюю фигню не обращайте внимания пытался фиксануть баг в моем проекте
Пожалуйста не бейте палками и повторюсь кому надо тот доделает и сделает красивее
На (noad)privateDLC походе
 
задумка норм, но реализация...
Идея гуд реализация 3/10
кто бы про реализацию пиздел, ты свои худы видел? Даже этот чел лучше сделает, так что не пизди про чужое дерьмо, пока сам лучше не станешь.
 
моя первая тема да знаю такое себе но кто хочет тот доработает и сделает норм (шрифты починил точнее цифры)
фон-https://workupload.com/file/URaV8FXLLWm
шрифт(не баганный)-https://workupload.com/archive/WxfrhJHxt7
ss(new)-Посмотреть вложение 320971
MainScreen:
Expand Collapse Copy
package im.expensive.ui.mainmenu;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import im.expensive.Expensive;
import im.expensive.utils.client.ClientUtil;
import im.expensive.utils.client.IMinecraft;
import im.expensive.utils.client.Vec2i;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.math.StopWatch;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.KawaseBlur;
import im.expensive.utils.render.Stencil;
import im.expensive.utils.render.font.Fonts;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.MultiplayerScreen;
import net.minecraft.client.gui.screen.OptionsScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.WorldSelectionScreen;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;

import java.net.URI;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ThreadLocalRandom;


public class MainScreen extends Screen implements IMinecraft {
public MainScreen() {
super(ITextComponent.getTextComponentOrEmpty(""));

    }

private final ResourceLocation backmenu = new ResourceLocation("expensive/images/mainscreen/bg_glow.png");
// private final ResourceLocation logo = new ResourceLocation("expensive/images/logo.png");

    private final List<Button> buttons = new ArrayList<>();
private Button altButton;

@Override
    public void init(Minecraft minecraft, int width, int height) {
 super.init(minecraft, width, height);

float widthButton = 100;
float heightButton = 25;
float spacing = 5;

// Create buttons list temporarily to calculate positions
        buttons.clear();

// Define actions
        Runnable singleplayerAction = () -> mc.displayGuiScreen(new WorldSelectionScreen(this));
Runnable multiplayerAction = () -> mc.displayGuiScreen(new MultiplayerScreen(this));
Runnable optionsAction = () -> mc.displayGuiScreen(new OptionsScreen(this, mc.gameSettings));
Runnable changelogAction = () -> mc.displayGuiScreen(new ChangelogScreen());
        Runnable telegramAction = () -> {
 try {
Util.getOSType().openURI(new URI("https://t.me/ваштгк"));
} catch (Exception e) {
                e.printStackTrace();
            }
        };
Runnable exitAction = mc::shutdownMinecraftApplet;
Runnable altAction = () -> mc.displayGuiScreen(Expensive.getInstance().getAltScreen());

// Add buttons to list to iterate for positioning
        // We'll initialize them with dummy coords first
        buttons.add(new Button(0, 0, widthButton, heightButton, "singleplayer", singleplayerAction));
buttons.add(new Button(0, 0, widthButton, heightButton, "multiplayer", multiplayerAction));
buttons.add(new Button(0, 0, widthButton, heightButton, "options", optionsAction));
buttons.add(new Button(0, 0, widthButton, heightButton, "changelog", changelogAction));
buttons.add(new Button(0, 0, widthButton, heightButton, "telegram", telegramAction));
buttons.add(new Button(0, 0, widthButton, heightButton, "exit", exitAction));

// Alt Manager button also at bottom
        altButton = new Button(0, 0, widthButton, heightButton, "alt", altAction);

// Calculate total width
        // 6 main buttons + 1 alt button
        int totalButtons = buttons.size() + 1;
float totalWidth = totalButtons * widthButton + (totalButtons - 1) * spacing;

float startX = (ClientUtil.calc(width) - totalWidth) / 2;
float y = ClientUtil.calc(height) - 50; // Position from bottom

        // Update positions
        for (int i = 0; i < buttons.size(); i++) {
Button b = buttons.get(i);
// Create new button with correct coords (Button class fields are final)
            buttons.set(i, new Button(startX + i * (widthButton + spacing), y, widthButton, heightButton, b.text, b.action));
        }

// Set Alt Button position (last one)
        altButton = new Button(startX + buttons.size() * (widthButton + spacing), y, widthButton, heightButton, "alt", altAction);
    }

private static final CopyOnWriteArrayList<Particle> particles = new CopyOnWriteArrayList<>();

private final StopWatch stopWatch = new StopWatch();
static boolean start = false;

@Override
    public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
 return super.mouseScrolled(mouseX, mouseY, delta);
    }

@Override
    public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
 super.render(matrixStack, mouseX, mouseY, partialTicks);
if (stopWatch.isReached(100)) {
particles.add(new Particle());
 stopWatch.reset();
        }
MainWindow mainWindow = mc.getMainWindow();
int windowWidth = ClientUtil.calc(mainWindow.getScaledWidth());
int windowHeight = ClientUtil.calc(mainWindow.getScaledHeight());

int logoWidth = 1920 / 2;
int logoHeight = 1080 / 2;

// Расчет координат для рисования логотипа по центру
        int xLogo = (windowWidth - logoWidth) / 2;
int yLogo = (windowHeight - logoHeight) / 2 + 50;
boolean small = mainWindow.getWidth() < 900 && mainWindow.getHeight() < 900;
 if (small) {
yLogo += 50;
        }
// Рисование логотипа по центру
        DisplayUtils.drawImage(backmenu, 0, 0, width, height, -1);

// Draw Time and Date in Center
        LocalDateTime now = LocalDateTime.now();
String timeText = now.format(DateTimeFormatter.ofPattern("HH:mm:ss"));
String dateText = now.format(DateTimeFormatter.ofPattern("dd.MM.yyyy"));

float centerX = width / 2f;
float centerY = height / 2f;

Fonts.sf.drawCenteredText(matrixStack, timeText, centerX, centerY - 20, -1, 40f); // Large time
        Fonts.sf.drawCenteredText(matrixStack, dateText, centerX, centerY + 20, -1, 20f); // Date below

        mc.gameRenderer.setupOverlayRendering(2);
// DisplayUtils.drawImage(logo, xLogo, yLogo, logoWidth, logoHeight, -1);

        KawaseBlur.blur.updateBlur(3, 4);
com.mojang.blaze3d.systems.RenderSystem.enableBlend();
com.mojang.blaze3d.systems.RenderSystem.defaultBlendFunc();
com.mojang.blaze3d.platform.GlStateManager.enableAlphaTest();
com.mojang.blaze3d.systems.RenderSystem.disableDepthTest();
com.mojang.blaze3d.platform.GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f);
        drawButtons(matrixStack, mouseX, mouseY, partialTicks);
 altButton.render(matrixStack, mouseX, mouseY, partialTicks);
com.mojang.blaze3d.systems.RenderSystem.enableDepthTest();

GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f);
GlStateManager.bindTexture(0);
GlStateManager.enableTexture();
GlStateManager.enableAlphaTest();
GlStateManager.colorMask(true, true, true, true);
GlStateManager.depthMask(true);

mc.gameRenderer.setupOverlayRendering();

    }

@Override
    public boolean charTyped(char codePoint, int modifiers) {
 return super.charTyped(codePoint, modifiers);
    }

@Override
    public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
 return false;
    }

@Override
    public boolean mouseClicked(double mouseX, double mouseY, int button) {
Vec2i fixed = ClientUtil.getMouse((int) mouseX, (int) mouseY);
buttons.forEach(b -> b.click(fixed.getX(), fixed.getY(), button));
 altButton.click(fixed.getX(), fixed.getY(), button);
 return super.mouseClicked(mouseX, mouseY, button);
    }

private void drawButtons(MatrixStack stack, int mX, int mY, float pt) {

buttons.forEach(b -> b.render(stack, mX, mY, pt));
    }


 private class Particle {

private final float x;
private float y;
private float size;

public Particle() {
x = ThreadLocalRandom.current().nextInt(0, mc.getMainWindow().getScaledWidth());
y = 0;
size = 0;
        }

public void update() {
y += 1f;
        }

public void render(MatrixStack stack) {
            update();
size += 0.1f;
GlStateManager.pushMatrix();
GlStateManager.translated((x + Math.sin((System.nanoTime() / 1000000000f)) * 5), y, 0);
GlStateManager.rotatef(size * 20, 0, 0, 1);
GlStateManager.translated(-(x + Math.sin((System.nanoTime() / 1000000000f)) * 5), -y, 0);
float multi = 1 - MathHelper.clamp((y / mc.getMainWindow().getScaledHeight()), 0, 1);
Fonts.damage.drawText(stack, "A", (float) (x + Math.sin((System.nanoTime() / 1000000000f)) * 5), y, -1, MathHelper.clamp(size * multi, 0, 9));
GlStateManager.popMatrix();
if (y >= mc.getMainWindow().getScaledHeight()) {
particles.remove(this);
            }
        }

    }

@AllArgsConstructor
    private class Button {
@Getter
        private final float x, y, width, height;
private String text;
private Runnable action;

public void render(MatrixStack stack, int mouseX, int mouseY, float pt) {
com.mojang.blaze3d.systems.RenderSystem.enableBlend();
com.mojang.blaze3d.systems.RenderSystem.defaultBlendFunc();

boolean hovered = MathUtil.isHovered(mouseX, mouseY, x, y, width, height);

// Draw blur background
            Stencil.initStencilToWrite();
DisplayUtils.drawRoundedRect(x, y + 2, width, height, 6f, -1);
Stencil.readStencilBuffer(1);
KawaseBlur.blur.BLURRED.draw();
Stencil.uninitStencilBuffer();

// Reset GL state after stencil/blur
            GlStateManager.bindTexture(0);
GlStateManager.enableTexture();
GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f);

// Полупрозрачный темный фон
            int bgColor = hovered ? ColorUtils.rgba(60, 60, 60, 180) : ColorUtils.rgba(30, 30, 30, 160);
DisplayUtils.drawRoundedRect(x, y + 2, width, height, 6f, bgColor);

// Reset state before text
            GlStateManager.bindTexture(0);
GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f);
com.mojang.blaze3d.systems.RenderSystem.enableBlend();
com.mojang.blaze3d.systems.RenderSystem.defaultBlendFunc();

int textColor = hovered ? ColorUtils.rgb(255, 255, 255) : ColorUtils.rgba(255, 255, 255, 200);
Fonts.montserrat.drawCenteredText(stack, text, x + width / 2f, y + height / 2f - 5.5f + 2, textColor, 10f);
        }

public void click(int mouseX, int mouseY, int button) {
if (MathUtil.isHovered(mouseX, mouseY, x, y, width, height)) {
 action.run();
            }
        }

    }


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