Начинающий
- Статус
- Оффлайн
- Регистрация
- 26 Сен 2025
- Сообщения
- 284
- Реакции
- 2
- Выберите загрузчик игры
- Fabric
сначала я пытался скидить рокстар, потом стало чуть чуть похуй.
ss;
ассеты
Scretch:
package wtf.ancient.display.screens.mainmenu;
import net.minecraft.client.render.RenderLayer;
import wtf.ancient.common.animation.Animation;
import wtf.ancient.common.animation.Direction;
import wtf.ancient.common.animation.inovated.EasingList;
import wtf.ancient.display.hud.DynamicIsland;
import wtf.ancient.display.screens.mainmenu.altscreen.AltScreen;
import wtf.ancient.utils.client.Constants;
import wtf.ancient.utils.client.text.TextAnimation;
import wtf.ancient.utils.display.color.ColorAssist;
import wtf.ancient.utils.display.font.FontRenderer;
import wtf.ancient.utils.display.font.Fonts;
import wtf.ancient.utils.display.font.msdf.FontsMsdf;
import wtf.ancient.utils.display.font.msdf.Instance;
import wtf.ancient.utils.display.geometry.Render2D;
import wtf.ancient.utils.display.gif.GifRender;
import wtf.ancient.utils.display.interfaces.QuickImports;
import wtf.ancient.utils.display.shape.ShapeProperties;
import wtf.ancient.common.animation.implement.Decelerate;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.screen.world.SelectWorldScreen;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import java.awt.Color;
import java.util.HashMap;
import java.util.Map;
public class MainMenu extends Screen implements QuickImports {
public static MainMenu INSTANCE = new MainMenu();
public int x, y, width, height;
private final TextAnimation textAnimation = new TextAnimation();
private boolean altVisible = false;
private Instance msdfRegular12;
private boolean lockScreenVisible = true;
private int lastHoveredIndex = -1;
private final Identifier HAT_TEX = Identifier.of("minecraft", "textures/mainmenu/govno.png");
private final GifRender gifRender = new GifRender("minecraft:gif/backgrounds/mainmenutype1", 1);
private final Decelerate altFadeAnimation = new Decelerate();
private final Decelerate mainFadeAnimation = new Decelerate();
private final Decelerate uiFade = (Decelerate) new Decelerate().setMs(220).setValue(1.0);
private boolean openingOtherScreen = false;
private final Decelerate lockScreenFadeAnimation = new Decelerate();
private AltScreen altScreen;
private long lastToggleTime = 0;
private final Decelerate dockHoverAnim = (Decelerate) new Decelerate().setMs(180).setValue(0.0);
private int hoveredIndex = -1;
private static final long TOGGLE_DELAY = 500;
private final Map<String, Animation> buttonAnimations = new HashMap<>();
private final Decelerate logoFlyAnim = (Decelerate) new Decelerate().setMs(600).setValue(1.0);
private boolean logoFlying = false;
private Runnable pendingAction = null;
private Instance mmButtonsFont;
private Instance iconMainButtonsFont;
private void ensureMenuMsdf() {
if (mmButtonsFont == null) {
mmButtonsFont = FontsMsdf.MAINMENU.getFont(35f);
}
if (iconMainButtonsFont == null) {
iconMainButtonsFont = FontsMsdf.ICONMAIN.getFont(45f);
}
}
public MainMenu() {
super(Text.of("MainMenu"));
altFadeAnimation.setMs(250).setValue(1.0);
mainFadeAnimation.setMs(250).setValue(1.0);
lockScreenFadeAnimation.setMs(300).setValue(1.0);
mainFadeAnimation.setDirection(Direction.BACKWARDS);
uiFade.setDirection(Direction.FORWARDS);
altFadeAnimation.setDirection(Direction.BACKWARDS);
lockScreenFadeAnimation.setDirection(Direction.FORWARDS);
}
private void drawButtonGlyph(DrawContext context, Instance font, String glyph,
float btnX, float btnY, float btnW, float btnH, int alpha) {
if (font == null || glyph == null || glyph.isEmpty() || alpha <= 0) return;
float gw = font.getWidth(glyph);
if (gw <= 0.001f) return;
var m = context.getMatrices();
float gh = font.getHeight();
float gx = btnX + (btnW - gw) / 2f;
float gy = btnY + (btnH - gh) / 2f + 1f;
Render2D.drawFont(m, font, glyph, gx, gy, new Color(255, 255, 255, alpha));
}
@Override
public void tick() {
super.tick();
textAnimation.updateText();
if (altScreen != null) altScreen.tick();
if (altFadeAnimation.isFinished(Direction.BACKWARDS)) altVisible = false;
if (openingOtherScreen
&& pendingAction != null
&& uiFade.isFinished(Direction.BACKWARDS)
&& !logoFlying) {
Runnable action = pendingAction;
pendingAction = null;
openingOtherScreen = false;
action.run();
}
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
mc.options.getGuiScale().setValue(2);
x = window.getScaledWidth();
y = window.getScaledHeight();
this.width = window.getScaledWidth();
this.height = window.getScaledHeight();
int darkPurple = new Color(20, 0, 50, 255).getRGB();
rectangle.render(
ShapeProperties.create(context.getMatrices(), 0, 0, width, height)
.round(0f)
.color(darkPurple)
.build()
);
image.setTexture("textures/mainmenu/background.png")
.render(ShapeProperties.create(context.getMatrices(), -275, -225, width + 500, height + 500)
.color(-1).build());
double mainAlpha = mainFadeAnimation.getOutput();
int mainAlphaInt = (int) (255 * mainAlpha);
java.time.LocalDateTime now = java.time.LocalDateTime.now();
java.time.LocalTime currentTime = java.time.LocalTime.now();
String timeString = String.format("%02d:%02d", currentTime.getHour(), currentTime.getMinute());
java.time.format.DateTimeFormatter dateFormatter = java.time.format.DateTimeFormatter.ofPattern("EEEE, d MMMM", java.util.Locale.forLanguageTag("ru"));
String dateString = now.format(dateFormatter);
double uiAlpha = uiFade.getOutput();
double uiVis = mainAlpha * uiAlpha;
int uiVis255 = (int) (255 * uiVis);
float timeY = height / 2f - 130f + 40f;
float timeCenterX = width / 2f + 5f;
float btnY = height / 2f + 40f;
double lockAlpha = lockScreenFadeAnimation.getOutput();
int lockAlphaInt = (int) (255 * lockAlpha);
if (lockAlpha > 0.01f) {
Fonts.getSize(120, Fonts.Type.BOLD).drawCenteredString(context.getMatrices(), timeString, width / 2, height / 2 - 40 + 40, applyAlpha(new Color(255, 255, 255).getRGB(), lockAlphaInt));
Fonts.getSize(25, Fonts.Type.REGULAR).drawCenteredString(context.getMatrices(), dateString, width / 2, height / 2 + 30 + 40, applyAlpha(new Color(200, 200, 200).getRGB(), lockAlphaInt));
Fonts.getSize(14, Fonts.Type.REGULAR).drawCenteredString(context.getMatrices(), "Нажмите ПРОБЕЛ чтобы продолжить", width / 2, height - 30, applyAlpha(new Color(150, 150, 150).getRGB(), lockAlphaInt));
}
if (mainAlpha > 0.01f) {
Fonts.getSize(250, Fonts.Type.BOLD).drawCenteredString(context.getMatrices(), timeString, timeCenterX, timeY, applyAlpha(new Color(255, 255, 255).getRGB(), mainAlphaInt));
Fonts.getSize(35, Fonts.Type.REGULAR).drawCenteredString(context.getMatrices(), dateString, width / 2, timeY, applyAlpha(new Color(200, 200, 200).getRGB(), mainAlphaInt));
DynamicIsland.getInstance().tick();
DynamicIsland.getInstance().drawDraggable(context);
float btn1X = width / 2f - 135f;
float btn2X = width / 2f - 75f;
float btn3X = width / 2f - 15f;
float btn4X = width / 2f + 45f;
blur.render(ShapeProperties.create(context.getMatrices(), btn1X + 20, btnY - 5, 50 + 190, 50 + 10)
.round(16f)
.quality(25f)
.color(new Color(175, 175, 175, 120).getRGB())
.build());
blur.render(ShapeProperties.create(context.getMatrices(), btn1X + 25, btnY, 50, 50)
.quality(15f).color(new Color(225, 225, 225, 100).getRGB())
.thickness(1.0f).round(16f).build());
blur.render(ShapeProperties.create(context.getMatrices(), btn2X + 25, btnY, 50, 50)
.quality(15f).thickness(1.0f).color(new Color(225, 225, 225, 100).getRGB()).round(16f).build());
blur.render(ShapeProperties.create(context.getMatrices(), btn3X + 25, btnY, 50, 50)
.quality(15f).thickness(1.0f).color(new Color(225, 225, 225, 100).getRGB()).round(16f).build());
blur.render(ShapeProperties.create(context.getMatrices(), btn4X + 25, btnY, 50, 50)
.quality(15f).thickness(1.0f).color(new Color(225, 225, 225, 100).getRGB()).round(16f).build());
ensureMenuMsdf();
float btnW = 50f;
float btnH = 50f;
float b1 = btn1X + 25;
float b2 = btn2X + 25;
float b3 = btn3X + 25;
float b4 = btn4X + 25;
hoveredIndex = -1;
if (isIn(mouseX, mouseY, b1, btnY, btnW, btnH)) hoveredIndex = 0;
else if (isIn(mouseX, mouseY, b2, btnY, btnW, btnH)) hoveredIndex = 1;
else if (isIn(mouseX, mouseY, b3, btnY, btnW, btnH)) hoveredIndex = 2;
else if (isIn(mouseX, mouseY, b4, btnY, btnW, btnH)) hoveredIndex = 3;
if (hoveredIndex != lastHoveredIndex) {
dockHoverAnim.setDirection(hoveredIndex != -1 ? Direction.FORWARDS : Direction.BACKWARDS);
dockHoverAnim.reset();
lastHoveredIndex = hoveredIndex;
}
double a = dockHoverAnim.getOutput();
if (a > 0.001f && hoveredIndex != -1) {
float hx = switch (hoveredIndex) {
case 0 -> b1;
case 1 -> b2;
case 2 -> b3;
default -> b4;
};
blur.render(ShapeProperties.create(context.getMatrices(), hx, btnY, btnW, btnH)
.quality(28f)
.round(16f)
.color(new Color(255, 255, 255, (int) (120 * a)).getRGB())
.build());
rectangle.render(ShapeProperties.create(context.getMatrices(), hx, btnY, btnW, btnH)
.round(16f)
.thickness(1.2f)
.outlineColor(applyAlpha(new Color(255, 255, 255, (int) (140 * a)).getRGB(), mainAlphaInt))
.color(0)
.build());
}
float lift = 2.0f * (float) dockHoverAnim.getOutput().floatValue();
int boost = (int) (55 * dockHoverAnim.getOutput());
int a1 = Math.min(255, mainAlphaInt + (hoveredIndex == 0 ? boost : 0));
int a2 = Math.min(255, mainAlphaInt + (hoveredIndex == 1 ? boost : 0));
int a3 = Math.min(255, mainAlphaInt + (hoveredIndex == 2 ? boost : 0));
int a4 = Math.min(255, mainAlphaInt + (hoveredIndex == 3 ? boost : 0));
drawButtonGlyph(context, mmButtonsFont, "A", b1, (btnY - 4 - (hoveredIndex == 0 ? lift : 0f)), btnW, btnH, a1);
drawButtonGlyph(context, mmButtonsFont, "B", b2 - 2, btnY - 3 - (hoveredIndex == 1 ? lift : 0f), btnW, btnH, a2);
drawButtonGlyph(context, iconMainButtonsFont, "L", b3 + 3, btnY - 11 - (hoveredIndex == 2 ? lift : 0f), btnW, btnH, a3);
drawButtonGlyph(context, mmButtonsFont, "C", b4 - 1, btnY - 3 - (hoveredIndex == 3 ? lift : 0f), btnW, btnH, a4);
float flyOffsetX = 0f;
if (logoFlying) {
double t = logoFlyAnim.getOutput();
float p = (float) t;
float eased = EasingList.SINE_BOTH.ease(p);
float maxLeft = 0f;
float maxRight = 600f;
flyOffsetX = maxLeft + (maxRight - maxLeft) * eased;
if (logoFlyAnim.isDone()) {
logoFlying = false;
if (pendingAction != null) {
Runnable action = pendingAction;
pendingAction = null;
action.run();
}
}
}
msdfRegular12 = FontsMsdf.SFPROREGULAR.getFont(9f);
FontRenderer logoFont = Fonts.getSize(500, Fonts.Type.LOGO);
float btn2CenterX = btn2X + btnW / 2f;
float logoX = btn2CenterX + 60f + flyOffsetX - 10;
float logoY = btnY - 325f;
logoFont.drawCenteredString(
context.getMatrices(),
"A",
logoX,
logoY,
applyAlpha(new Color(255, 255, 255).getRGB(), mainAlphaInt)
);
int hatWidth = 240, hatHeight = 220;
int hatX = (int) (logoX - hatWidth / 2f - 25f);
int hatY = (int) (logoY - hatHeight + 140f);
context.drawTexture(
RenderLayer::getGuiTextured,
HAT_TEX,
hatX, hatY,
0f, 0f,
hatWidth, hatHeight,
hatWidth, hatHeight,
hatWidth, hatHeight
);
rectangle.render(ShapeProperties.create(context.getMatrices(), width / 2 - 75, height - 10, 150, 3)
.round(2f).build());
String text = Constants.build;
float textWidth = Fonts.getSize(12, Fonts.Type.DEFAULT).getStringWidth(text);
Fonts.getSize(12, Fonts.Type.DEFAULT).drawString(context.getMatrices(), text, context.getScaledWindowWidth() - textWidth - 3, context.getScaledWindowHeight() - 5.5f, applyAlpha(ColorAssist.getText(0.35f), mainAlphaInt));
}
double altAlpha = altFadeAnimation.getOutput();
if (altVisible || altAlpha > 0.01f) {
float centerX = width / 2f - 80;
float centerY = height / 2f - 105;
if (altScreen == null) {
altScreen = new AltScreen(centerX, centerY);
} else {
altScreen.updatePosition(centerX, centerY);
}
int altAlphaInt = (int) (255 * altAlpha);
Color buttonColor = new Color(50, 50, 50, (int)(55 * altAlpha));
Color outlineColor = new Color(100, 100, 100, (int)(95 * altAlpha));
Color gradientColor = new Color(80, 80, 80, (int)(95 * altAlpha));
Color textColor = new Color(200, 200, 200, altAlphaInt);
Color bgColor = new Color(30, 30, 30, (int)(255 * altAlpha));
altScreen.render(context, buttonColor, outlineColor, gradientColor, textColor, bgColor);
}
super.render(context, mouseX, mouseY, delta);
}
private int applyAlpha(int color, int alpha) {
Color c = new Color(color, true);
int newAlpha = (int) ((c.getAlpha() / 255.0) * alpha);
return new Color(c.getRed(), c.getGreen(), c.getBlue(), Math.min(255, newAlpha)).getRGB();
}
@Override
public boolean mouseClicked(double mx, double my, int btn) {
if (altVisible && altFadeAnimation.getOutput() > 0.5 && altScreen != null) {
return altScreen.mouseClicked(mx, my, btn);
}
if (mainFadeAnimation.getOutput() > 0.5 && btn == 0) {
float btnW = 50f;
float btnH = 50f;
float btnY = height / 2f + 40f;
float btn1X = width / 2f - 135f;
float btn2X = width / 2f - 75f;
float btn3X = width / 2f - 15f;
float btn4X = width / 2f + 45f;
Runnable action = null;
if (isIn(mx, my, btn1X + 25, btnY, btnW, btnH)) {
action = () -> mc.setScreen(new SelectWorldScreen(this));
}
else if (isIn(mx, my, btn2X + 25, btnY, btnW, btnH)) {
action = () -> mc.setScreen(new MultiplayerScreen(this));
}
else if (isIn(mx, my, btn3X + 25, btnY, btnW, btnH)) {
action = this::toggleAlt;
}
else if (isIn(mx, my, btn4X + 25, btnY, btnW, btnH)) {
action = () -> mc.setScreen(new net.minecraft.client.gui.screen.option.OptionsScreen(this, mc.options));
}
float exitX = width / 2f - 75f;
float exitY = height - 10f;
float exitW = 150f;
float exitH = 10f;
if (action == null && isIn(mx, my, exitX, exitY - 3f, exitW, exitH)) {
action = () -> mc.stop();
}
if (action != null) {
pendingAction = action;
openingOtherScreen = true;
uiFade.setDirection(Direction.BACKWARDS);
uiFade.reset();
dockHoverAnim.setDirection(Direction.BACKWARDS);
dockHoverAnim.reset();
logoFlying = true;
logoFlyAnim.setDirection(Direction.FORWARDS);
logoFlyAnim.reset();
return true;
}
}
return super.mouseClicked(mx, my, btn);
}
@Override
public boolean mouseScrolled(double mx, double my, double h, double v) {
if (altVisible && altFadeAnimation.getOutput() > 0.5 && altScreen != null) {
return altScreen.mouseScrolled(mx, my, v);
}
return super.mouseScrolled(mx, my, h, v);
}
@Override
public boolean mouseDragged(double mx, double my, int btn, double dx, double dy) {
if (altVisible && altFadeAnimation.getOutput() > 0.5 && altScreen != null) {
return altScreen.mouseDragged(mx, my, btn);
}
return super.mouseDragged(mx, my, btn, dx, dy);
}
@Override
public boolean mouseReleased(double mx, double my, int btn) {
if (altScreen != null) altScreen.mouseReleased();
return super.mouseReleased(mx, my, btn);
}
@Override
public boolean charTyped(char c, int m) {
if (altVisible && altFadeAnimation.getOutput() > 0.5 && altScreen != null) {
return altScreen.charTyped(c);
}
return super.charTyped(c, m);
}
@Override
public boolean keyPressed(int k, int s, int m) {
if (k == org.lwjgl.glfw.GLFW.GLFW_KEY_SPACE && lockScreenVisible) {
lockScreenVisible = false;
lockScreenFadeAnimation.setDirection(Direction.BACKWARDS);
lockScreenFadeAnimation.reset();
mainFadeAnimation.setDirection(Direction.FORWARDS);
mainFadeAnimation.reset();
return true;
}
if (k == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) {
if (altVisible) {
toggleAlt();
return true;
}
if (!lockScreenVisible) {
lockScreenVisible = true;
lockScreenFadeAnimation.setDirection(Direction.FORWARDS);
lockScreenFadeAnimation.reset();
mainFadeAnimation.setDirection(Direction.BACKWARDS);
mainFadeAnimation.reset();
return true;
}
return false;
}
if (altVisible && altFadeAnimation.getOutput() > 0.5 && altScreen != null && altScreen.keyPressed(k)) {
return true;
}
return super.keyPressed(k, s, m);
}
private boolean isIn(double mx, double my, float x, float y, float w, float h) {
return mx >= x && mx <= x + w && my >= y && my <= y + h;
}
private void toggleAlt() {
long currentTime = System.currentTimeMillis();
if (currentTime - lastToggleTime < TOGGLE_DELAY) {
return;
}
lastToggleTime = currentTime;
if (!altVisible) {
altVisible = true;
altFadeAnimation.setDirection(Direction.FORWARDS);
altFadeAnimation.reset();
mainFadeAnimation.setDirection(Direction.BACKWARDS);
mainFadeAnimation.reset();
if (altScreen != null) altScreen.reset();
} else {
altFadeAnimation.setDirection(Direction.BACKWARDS);
altFadeAnimation.reset();
mainFadeAnimation.setDirection(Direction.FORWARDS);
mainFadeAnimation.reset();
if (altScreen != null) altScreen.reset();
}
}
}
ss;
ассеты
а так пойдет базару зиро