- Выберите загрузчик игры
- OptiFine
Меин скрин на экспу 3.1.dw:
Пожалуйста, авторизуйтесь для просмотра ссылки.
ss:
Пожалуйста, авторизуйтесь для просмотра ссылки.
Код:
package DickRecode.ui.mainmenu;
import DickRecode.utils.client.IMinecraft;
import DickRecode.utils.math.MathUtil;
import DickRecode.utils.render.ColorUtils;
import DickRecode.utils.render.DisplayUtils;
import DickRecode.utils.render.font.Fonts;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
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.text.ITextComponent;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
public class MainScreen extends Screen implements IMinecraft {
private final List<MenuButton> buttons = new ArrayList<>();
private float screenAlpha = 0f;
private static final ResourceLocation BG_TEXTURE = new ResourceLocation("minecraft", "dick/images/backk.png");
private static final ResourceLocation ICON_SINGLE = new ResourceLocation("minecraft", "dick/images/single.png");
private static final ResourceLocation ICON_MULTI = new ResourceLocation("minecraft", "dick/images/multy.png");
private static final ResourceLocation ICON_SETTINGS = new ResourceLocation("minecraft", "dick/images/settings.png");
private static final ResourceLocation ICON_ALTMGR = new ResourceLocation("minecraft", "dick/images/altmgr.png");
private static final ResourceLocation ICON_EXIT = new ResourceLocation("minecraft", "dick/images/quit.png");
private boolean textureLoaded = false;
private final SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm");
private final SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
private final SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE", new Locale("ru"));
public MainScreen() {
super(ITextComponent.getTextComponentOrEmpty(""));
}
@Override
public void init(Minecraft minecraft, int width, int height) {
super.init(minecraft, width, height);
try {
mc.getTextureManager().getTexture(BG_TEXTURE);
textureLoaded = true;
} catch (Exception e) {
textureLoaded = false;
}
float buttonWidth = 60f;
float buttonHeight = 60f;
float centerX = (float) width / 2f - buttonWidth / 2f;
float startY = height / 2f + 50f;
float spacing = 15f;
buttons.clear();
buttons.add(new MenuButton(centerX - 130, startY, buttonWidth, buttonHeight, ICON_SINGLE, () -> {
mc.displayGuiScreen(new WorldSelectionScreen(this));
}));
buttons.add(new MenuButton(centerX - 65, startY, buttonWidth, buttonHeight, ICON_MULTI, () -> {
mc.displayGuiScreen(new MultiplayerScreen(this));
}));
buttons.add(new MenuButton(centerX, startY, buttonWidth, buttonHeight, ICON_ALTMGR, () -> {
mc.displayGuiScreen(new AltWidget());
}));
buttons.add(new MenuButton(centerX + 65, startY, buttonWidth, buttonHeight, ICON_SETTINGS, () -> {
mc.displayGuiScreen(new OptionsScreen(this, mc.gameSettings));
}));
buttons.add(new MenuButton(centerX + 130, startY, buttonWidth, buttonHeight, ICON_EXIT, () -> {
mc.shutdownMinecraftApplet();
}));
buttons.forEach(MenuButton::init);
screenAlpha = 0f;
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
MainWindow window = mc.getMainWindow();
if (textureLoaded) {
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
mc.getTextureManager().bindTexture(BG_TEXTURE);
blit(matrixStack, 0, 0, 0f, 0f, width, height, width, height);
RenderSystem.disableBlend();
} else {
fill(matrixStack, 0, 0, width, height, ColorUtils.rgba(0, 0, 0, 255));
}
screenAlpha = MathUtil.fast(screenAlpha, 0.85f, 5f);
int bgColor = ColorUtils.rgba(0, 0, 0, (int)(160 * screenAlpha));
fill(matrixStack, 0, 0, width, height, bgColor);
float centerX = width / 2f;
float centerY = height / 2f;
renderDateTime(matrixStack, centerX, centerY);
for (MenuButton btn : buttons) {
btn.render(matrixStack, mouseX, mouseY, screenAlpha);
}
}
private void renderDateTime(MatrixStack ms, float centerX, float centerY) {
Date now = new Date();
String time = timeFormat.format(now);
String date = dateFormat.format(now);
String day = dayFormat.format(now);
day = day.substring(0, 1).toUpperCase() + day.substring(1);
int textColor = ColorUtils.rgba(255, 255, 255, (int)(255 * screenAlpha));
Fonts.sfbold.drawCenteredText(ms, time, centerX, centerY - 130f, textColor, 48f);
Fonts.sfui.drawCenteredText(ms, date, centerX, centerY - 75f, textColor, 20f);
Fonts.sfui.drawCenteredText(ms, day, centerX, centerY - 50f, textColor, 16f);
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
for (MenuButton btn : buttons) {
if (btn.mouseClicked((int) mouseX, (int) mouseY, button)) {
return true;
}
}
return super.mouseClicked(mouseX, mouseY, button);
}
private static class MenuButton {
private final float x, y, width, height;
private final ResourceLocation icon;
private final Runnable action;
private float hoverAnim = 0f;
public MenuButton(float x, float y, float width, float height, ResourceLocation icon, Runnable action) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.icon = icon;
this.action = action;
}
public void init() {
hoverAnim = 0f;
}
public void render(MatrixStack ms, int mouseX, int mouseY, float screenAlpha) {
boolean hovered = isHovered(mouseX, mouseY);
hoverAnim = MathUtil.fast(hoverAnim, hovered ? 1f : 0f, 15f);
float scale = 1.0f + hoverAnim * 0.15f;
float iconSize = 32 * scale;
float iconX = x + width/2 - iconSize/2;
float iconY = y + height/2 - iconSize/2;
int bgColor = ColorUtils.rgba(
30 + (int)(hoverAnim * 20),
30 + (int)(hoverAnim * 20),
40 + (int)(hoverAnim * 35),
(int)(220 * screenAlpha)
);
DisplayUtils.drawRoundedRect(x, y, width, height, 14f, bgColor);
if (hoverAnim > 0.05f) {
int outlineColor = ColorUtils.rgba(100, 150, 255, (int)(100 * hoverAnim * screenAlpha));
DisplayUtils.drawRoundedRect(x - 2f, y - 2f, width + 4f, height + 4f, 16f, outlineColor);
}
try {
RenderSystem.pushMatrix();
RenderSystem.translatef(iconX + iconSize/2, iconY + iconSize/2, 0);
RenderSystem.scalef(scale, scale, 1);
RenderSystem.translatef(-(iconX + iconSize/2), -(iconY + iconSize/2), 0);
DisplayUtils.drawImage(icon, iconX, iconY, iconSize, iconSize, -1);
RenderSystem.popMatrix();
} catch (Exception e) {
Fonts.sfbold.drawCenteredText(ms, "?", x + width/2, y + height/2 - 4, -1, 20f);
}
}
public boolean isHovered(int mouseX, int mouseY) {
return mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + height;
}
public boolean mouseClicked(int mouseX, int mouseY, int button) {
if (isHovered(mouseX, mouseY) && button == 0) {
action.run();
return true;
}
return false;
}
}
}