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

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

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
10 Янв 2025
Сообщения
134
Реакции
0
Выберите загрузчик игры
  1. Прочие моды
всем хай очередной завоз
щит гпт присутствует тк я не мог понять почему не идет музыка(если у вас открыто два потока музыки или видео то приоретет будет на тот который был запущен раннее)
ОБЯЗАТЕЛЬНО НУЖНА ЛИБКА БЕЗ НЕЕ НИЧЕГО НЕ РАБОТАЕТ -
Пожалуйста, авторизуйтесь для просмотра ссылки.

Закидывать либку в вашу папку с либками
сс -
Пожалуйста, авторизуйтесь для просмотра ссылки.
(смотреть со звуком)
код -
Java:
Expand Collapse Copy
import dev.kodek.client.api.events.orbit.EventHandler;
import dev.kodek.client.managers.events.render.Render2DEvent;
import dev.kodek.client.screen.InterFace;
import dev.kodek.client.screen.hud.IRenderer;
import dev.kodek.client.utils.animation.Animation;
import dev.kodek.client.utils.animation.util.Easings;
import dev.kodek.client.utils.render.color.ColorUtil;
import dev.kodek.client.utils.render.draw.RenderUtil;
import dev.kodek.client.utils.render.draw.Round;
import dev.kodek.client.utils.render.font.Fonts;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.util.ResourceLocation;
import net.mojang.blaze3d.matrix.MatrixStack;
import org.lwjgl.opengl.GL11;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class MusicBarRenderer implements IRenderer {

    private String song = null;
    private String artist = null;
    private boolean playing = false;
    private byte[] cover = null;
    private boolean coverLoaded = false;

    private ResourceLocation coverTexture = null;
    private static final ResourceLocation DEFAULT_COVER = new ResourceLocation("texture/Cat.png");

    private final float[] barH = {0f, 0f, 0f, 0f};
    private final float[] barTarget = {4f, 7f, 5f, 3f};
    private long lastWave = 0;

    private final Animation fade = new Animation();
    private final Animation bossAnim = new Animation();

    private float scroll = 0f;
    private long lastScroll = System.currentTimeMillis();

    private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(r -> {
        Thread t = new Thread(r, "music-thread");
        t.setDaemon(true);
        return t;
    });

    private static final float H = 18f;
    private static final float COVER_SIZE = 14f;
    private static final float TIME_SIZE = 8f;
    private static final float TEXT_SIZE = 6.5f;
    private static final float PAD = 5f;
    private static final float GAP = 7f;
    private static final float MAX_TEXT = 95f;
    private static final float EQ_W = 14f;
    private static final float BOSS_OFFSET = 28f;

    public MusicBarRenderer() {
        executor.scheduleAtFixedRate(this::fetchMusic, 0, 100, TimeUnit.MILLISECONDS);
        fade.set(0.0);
        bossAnim.set(0.0);
    }

    private void fetchMusic() {
        try {
            Class<?> mt = Class.forName("by.bonenaut7.mediatransport4j.api.MediaTransport");
            mt.getMethod("init").invoke(null);
            java.util.List<?> sessions = (java.util.List<?>) mt.getMethod("getMediaSessions").invoke(null);

            if (sessions != null && !sessions.isEmpty()) {
                Object active = null;
                for (Object s : sessions) {
                    boolean play = (Boolean) s.getClass().getMethod("isPlaying").invoke(s);
                    if (play) {
                        active = s;
                        break;
                    }
                }

                if (active == null) {
                    active = sessions.get(0);
                }

                String title = (String) active.getClass().getMethod("getTitle").invoke(active);
                String artistName = (String) active.getClass().getMethod("getArtist").invoke(active);
                boolean isPlaying = (Boolean) active.getClass().getMethod("isPlaying").invoke(active);

                song = title != null ? title : "Unknown";
                artist = artistName != null ? artistName : "Artist";
                playing = isPlaying;

                try {
                    Object thumb = active.getClass().getMethod("getThumbnail").invoke(active);
                    if (thumb instanceof BufferedImage) {
                        BufferedImage img = (BufferedImage) thumb;
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        ImageIO.write(img, "png", baos);
                        byte[] newCover = baos.toByteArray();

                        if (cover == null || !java.util.Arrays.equals(cover, newCover)) {
                            cover = newCover;
                            coverLoaded = false;
                        }
                    }
                } catch (NoSuchMethodException ignored) {}
            } else {
                song = null;
                cover = null;
                coverLoaded = false;
            }
        } catch (ClassNotFoundException ignored) {
            executor.shutdown();
        } catch (Exception ignored) {
            song = null;
        }
        updateBars();
    }

    private void loadCover() {
        if (coverLoaded) return;

        if (cover != null && cover.length > 0) {
            try {
                InputStream in = new ByteArrayInputStream(cover);
                BufferedImage img = ImageIO.read(in);
                if (img != null) {
                    int w = img.getWidth();
                    int h = img.getHeight();
                    NativeImage nativeImg = new NativeImage(w, h, false);

                    for (int x = 0; x < w; x++) {
                        for (int y = 0; y < h; y++) {
                            nativeImg.setPixelRGBA(x, y, img.getRGB(x, y));
                        }
                    }

                    DynamicTexture dynTex = new DynamicTexture(nativeImg);
                    coverTexture = mc.getTextureManager().getDynamicTextureLocation("music_cover_" + System.currentTimeMillis(), dynTex);
                    coverLoaded = true;
                    return;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        coverTexture = DEFAULT_COVER;
        coverLoaded = true;
    }

    private void updateBars() {
        if (playing) {
            if (System.currentTimeMillis() - lastWave > 95) {
                lastWave = System.currentTimeMillis();
                barTarget[0] = 3f + (float)(Math.random() * 7f);
                barTarget[1] = 2f + (float)(Math.random() * 10f);
                barTarget[2] = 4f + (float)(Math.random() * 5f);
                barTarget[3] = 3f + (float)(Math.random() * 6f);
            }
        } else {
            for (int i = 0; i < 4; i++) barTarget[i] = 0f;
        }
        for (int i = 0; i < 4; i++)
            barH[i] += (barTarget[i] - barH[i]) * 0.22f;
    }

    private boolean hasBoss() {
        return mc.ingameGUI.getBossOverlay().getMapBossInfos() != null &&
                !mc.ingameGUI.getBossOverlay().getMapBossInfos().isEmpty();
    }

    @Override
    @EventHandler
    public void render(Render2DEvent event) {
        if (song == null) {
            fade.run(0.0, 0.2, Easings.EXPO_IN, false);
            fade.update();
            bossAnim.update();
            return;
        }

        loadCover();

        bossAnim.update();
        boolean bossHere = hasBoss();
        bossAnim.run(bossHere ? 1.0 : 0.0, 0.25, Easings.EXPO_OUT, false);
        float bossShift = (float) bossAnim.get() * BOSS_OFFSET;

        fade.update();
        fade.run(1.0, 0.3, Easings.EXPO_OUT, false);
        float alpha = (float) fade.get();
        if (alpha < 0.02f) return;

        InterFace ui = InterFace.getInstance();
        MatrixStack stack = event.getMatrix();
        int accent = ui.themeColor();

        int screenW = mc.getMainWindow().getScaledWidth();

        String time = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm"));
        float timeW = Fonts.SFP_BOLD.getWidth(time, TIME_SIZE);

        String text = song + " - " + artist;
        float textW = Math.min(Fonts.SFP_MEDIUM.getWidth(text, TEXT_SIZE), MAX_TEXT);

        float wifiW = Fonts.ICON_DESHUX.getWidth("n", TEXT_SIZE + 0.5f);
        float pillW = PAD + COVER_SIZE + GAP + textW + GAP + EQ_W + PAD;
        float totalW = timeW + GAP + pillW + GAP + wifiW;

        float startX = (screenW - totalW) / 2f;
        float startY = 0f + bossShift;
        float centerY = startY + H / 2f;

        stack.push();
        stack.translate(screenW / 2f, centerY, 0);
        stack.scale(alpha, alpha, 1f);
        stack.translate(-screenW / 2f, -centerY, 0);

        float curX = startX;

        Fonts.SFP_BOLD.draw(stack, time, curX, centerY - TIME_SIZE / 2f - 0.5f,
                ColorUtil.getColor(210, (int)(225 * alpha)), TIME_SIZE);
        curX += timeW + GAP;

        float pillX = curX;
        RenderUtil.Shadow.drawShadow(stack, pillX - 3, startY - 3, pillW + 6, H + 6,
                8, alpha * 0.35f, ColorUtil.getColor(0));
        RenderUtil.Rounded.smooth(stack, pillX, startY, pillW, H,
                ColorUtil.getColor(28, 22, 38, (int)(218 * alpha)), Round.of(H / 2f));
        RenderUtil.Rounded.roundedOutline(stack, pillX, startY, pillW, H, 0.75f,
                ColorUtil.replAlpha(accent, alpha * 0.2f), Round.of(H / 2f));

        float innerX = pillX + PAD;

        float coverY = centerY - COVER_SIZE / 2f;
        RenderUtil.Rounded.smooth(stack, innerX, coverY, COVER_SIZE, COVER_SIZE,
                ColorUtil.replAlpha(accent, alpha * 0.32f), Round.of(COVER_SIZE / 3f));

        if (coverTexture != null) {
            mc.getTextureManager().bindTexture(coverTexture);
            RenderUtil.Texture.customRound(stack, innerX, coverY, COVER_SIZE, COVER_SIZE, alpha, 0, 0, 0, 0, Round.of(COVER_SIZE / 3f));
        } else {
            Fonts.ICON_DESHUX.draw(stack, "v",
                    innerX + COVER_SIZE / 2f - 3.5f, coverY + COVER_SIZE / 2f - 3.5f,
                    ColorUtil.replAlpha(accent, alpha * 0.75f), TEXT_SIZE);
        }

        innerX += COVER_SIZE + GAP;

        drawScrollText(stack, text, innerX, centerY - TEXT_SIZE / 2f - 0.5f, textW, TEXT_SIZE,
                ColorUtil.getColor(215, (int)(218 * alpha)));
        innerX += textW + GAP;

        float barW = 2.5f, barGap = 1.5f;
        float barBottom = centerY + 4f;
        if (playing) {
            for (int i = 0; i < 4; i++) {
                float bh = Math.max(1f, Math.min(barH[i] * (H / 11f), H - 4f));
                RenderUtil.Rounded.smooth(stack,
                        innerX + i * (barW + barGap), barBottom - bh,
                        barW, bh,
                        ColorUtil.replAlpha(accent, alpha * 0.85f), Round.of(barW / 2f));
            }
        } else {
            float pauseH = 8f, pauseW = 2f, pauseGap = 2f;
            float pauseX = innerX + (EQ_W - pauseW * 2 - pauseGap) / 2f;
            float pauseY = centerY - pauseH / 2f;
            RenderUtil.Rounded.smooth(stack, pauseX, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
            RenderUtil.Rounded.smooth(stack, pauseX + pauseW + pauseGap, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
        }

        curX = pillX + pillW + GAP;
        Fonts.ICON_DESHUX.draw(stack, "n", curX, centerY - (TEXT_SIZE + 0.5f) / 2f - 0.5f,
                ColorUtil.getColor(195, (int)(200 * alpha)), TEXT_SIZE + 0.5f);

        stack.pop();
    }

    private void drawScrollText(MatrixStack stack, String text, float x, float y,
                                float maxW, float fontSize, int color) {
        float textW = Fonts.SFP_MEDIUM.getWidth(text, fontSize);
        if (textW <= maxW) {
            Fonts.SFP_MEDIUM.draw(stack, text, x, y, color, fontSize);
            scroll = 0f;
            return;
        }

        long now = System.currentTimeMillis();
        float delta = (now - lastScroll) / 1000f;
        lastScroll = now;
        float speed = 20f, gap = 28f;
        scroll += delta * speed;
        if (scroll > textW + gap) scroll = 0f;

        double scale = mc.getMainWindow().getScaleFactor();
        int sx = (int)(x * scale);
        int sy = (int)(mc.getFramebuffer().framebufferHeight - (y + fontSize + 4) * scale);
        int sw = (int)(maxW * scale);
        int sh = (int)((fontSize + 6) * scale);

        GL11.glEnable(GL11.GL_SCISSOR_TEST);
        GL11.glScissor(sx, sy, sw, sh);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll, y, color, fontSize);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll + textW + gap, y, color, fontSize);
        GL11.glDisable(GL11.GL_SCISSOR_TEST);
    }
}
всем хай очередной завоз
щит гпт присутствует тк я не мог понять почему не идет музыка(если у вас открыто два потока музыки или видео то приоретет будет на тот который был запущен раннее)
ОБЯЗАТЕЛЬНО НУЖНА ЛИБКА БЕЗ НЕЕ НИЧЕГО НЕ РАБОТАЕТ -
Пожалуйста, авторизуйтесь для просмотра ссылки.

Закидывать либку в вашу папку с либками
сс -
Пожалуйста, авторизуйтесь для просмотра ссылки.
(смотреть со звуком)
код -
Java:
Expand Collapse Copy
import dev.kodek.client.api.events.orbit.EventHandler;
import dev.kodek.client.managers.events.render.Render2DEvent;
import dev.kodek.client.screen.InterFace;
import dev.kodek.client.screen.hud.IRenderer;
import dev.kodek.client.utils.animation.Animation;
import dev.kodek.client.utils.animation.util.Easings;
import dev.kodek.client.utils.render.color.ColorUtil;
import dev.kodek.client.utils.render.draw.RenderUtil;
import dev.kodek.client.utils.render.draw.Round;
import dev.kodek.client.utils.render.font.Fonts;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.util.ResourceLocation;
import net.mojang.blaze3d.matrix.MatrixStack;
import org.lwjgl.opengl.GL11;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class MusicBarRenderer implements IRenderer {

    private String song = null;
    private String artist = null;
    private boolean playing = false;
    private byte[] cover = null;
    private boolean coverLoaded = false;

    private ResourceLocation coverTexture = null;
    private static final ResourceLocation DEFAULT_COVER = new ResourceLocation("texture/Cat.png");

    private final float[] barH = {0f, 0f, 0f, 0f};
    private final float[] barTarget = {4f, 7f, 5f, 3f};
    private long lastWave = 0;

    private final Animation fade = new Animation();
    private final Animation bossAnim = new Animation();

    private float scroll = 0f;
    private long lastScroll = System.currentTimeMillis();

    private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(r -> {
        Thread t = new Thread(r, "music-thread");
        t.setDaemon(true);
        return t;
    });

    private static final float H = 18f;
    private static final float COVER_SIZE = 14f;
    private static final float TIME_SIZE = 8f;
    private static final float TEXT_SIZE = 6.5f;
    private static final float PAD = 5f;
    private static final float GAP = 7f;
    private static final float MAX_TEXT = 95f;
    private static final float EQ_W = 14f;
    private static final float BOSS_OFFSET = 28f;

    public MusicBarRenderer() {
        executor.scheduleAtFixedRate(this::fetchMusic, 0, 100, TimeUnit.MILLISECONDS);
        fade.set(0.0);
        bossAnim.set(0.0);
    }

    private void fetchMusic() {
        try {
            Class<?> mt = Class.forName("by.bonenaut7.mediatransport4j.api.MediaTransport");
            mt.getMethod("init").invoke(null);
            java.util.List<?> sessions = (java.util.List<?>) mt.getMethod("getMediaSessions").invoke(null);

            if (sessions != null && !sessions.isEmpty()) {
                Object active = null;
                for (Object s : sessions) {
                    boolean play = (Boolean) s.getClass().getMethod("isPlaying").invoke(s);
                    if (play) {
                        active = s;
                        break;
                    }
                }

                if (active == null) {
                    active = sessions.get(0);
                }

                String title = (String) active.getClass().getMethod("getTitle").invoke(active);
                String artistName = (String) active.getClass().getMethod("getArtist").invoke(active);
                boolean isPlaying = (Boolean) active.getClass().getMethod("isPlaying").invoke(active);

                song = title != null ? title : "Unknown";
                artist = artistName != null ? artistName : "Artist";
                playing = isPlaying;

                try {
                    Object thumb = active.getClass().getMethod("getThumbnail").invoke(active);
                    if (thumb instanceof BufferedImage) {
                        BufferedImage img = (BufferedImage) thumb;
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        ImageIO.write(img, "png", baos);
                        byte[] newCover = baos.toByteArray();

                        if (cover == null || !java.util.Arrays.equals(cover, newCover)) {
                            cover = newCover;
                            coverLoaded = false;
                        }
                    }
                } catch (NoSuchMethodException ignored) {}
            } else {
                song = null;
                cover = null;
                coverLoaded = false;
            }
        } catch (ClassNotFoundException ignored) {
            executor.shutdown();
        } catch (Exception ignored) {
            song = null;
        }
        updateBars();
    }

    private void loadCover() {
        if (coverLoaded) return;

        if (cover != null && cover.length > 0) {
            try {
                InputStream in = new ByteArrayInputStream(cover);
                BufferedImage img = ImageIO.read(in);
                if (img != null) {
                    int w = img.getWidth();
                    int h = img.getHeight();
                    NativeImage nativeImg = new NativeImage(w, h, false);

                    for (int x = 0; x < w; x++) {
                        for (int y = 0; y < h; y++) {
                            nativeImg.setPixelRGBA(x, y, img.getRGB(x, y));
                        }
                    }

                    DynamicTexture dynTex = new DynamicTexture(nativeImg);
                    coverTexture = mc.getTextureManager().getDynamicTextureLocation("music_cover_" + System.currentTimeMillis(), dynTex);
                    coverLoaded = true;
                    return;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        coverTexture = DEFAULT_COVER;
        coverLoaded = true;
    }

    private void updateBars() {
        if (playing) {
            if (System.currentTimeMillis() - lastWave > 95) {
                lastWave = System.currentTimeMillis();
                barTarget[0] = 3f + (float)(Math.random() * 7f);
                barTarget[1] = 2f + (float)(Math.random() * 10f);
                barTarget[2] = 4f + (float)(Math.random() * 5f);
                barTarget[3] = 3f + (float)(Math.random() * 6f);
            }
        } else {
            for (int i = 0; i < 4; i++) barTarget[i] = 0f;
        }
        for (int i = 0; i < 4; i++)
            barH[i] += (barTarget[i] - barH[i]) * 0.22f;
    }

    private boolean hasBoss() {
        return mc.ingameGUI.getBossOverlay().getMapBossInfos() != null &&
                !mc.ingameGUI.getBossOverlay().getMapBossInfos().isEmpty();
    }

    @Override
    @EventHandler
    public void render(Render2DEvent event) {
        if (song == null) {
            fade.run(0.0, 0.2, Easings.EXPO_IN, false);
            fade.update();
            bossAnim.update();
            return;
        }

        loadCover();

        bossAnim.update();
        boolean bossHere = hasBoss();
        bossAnim.run(bossHere ? 1.0 : 0.0, 0.25, Easings.EXPO_OUT, false);
        float bossShift = (float) bossAnim.get() * BOSS_OFFSET;

        fade.update();
        fade.run(1.0, 0.3, Easings.EXPO_OUT, false);
        float alpha = (float) fade.get();
        if (alpha < 0.02f) return;

        InterFace ui = InterFace.getInstance();
        MatrixStack stack = event.getMatrix();
        int accent = ui.themeColor();

        int screenW = mc.getMainWindow().getScaledWidth();

        String time = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm"));
        float timeW = Fonts.SFP_BOLD.getWidth(time, TIME_SIZE);

        String text = song + " - " + artist;
        float textW = Math.min(Fonts.SFP_MEDIUM.getWidth(text, TEXT_SIZE), MAX_TEXT);

        float wifiW = Fonts.ICON_DESHUX.getWidth("n", TEXT_SIZE + 0.5f);
        float pillW = PAD + COVER_SIZE + GAP + textW + GAP + EQ_W + PAD;
        float totalW = timeW + GAP + pillW + GAP + wifiW;

        float startX = (screenW - totalW) / 2f;
        float startY = 0f + bossShift;
        float centerY = startY + H / 2f;

        stack.push();
        stack.translate(screenW / 2f, centerY, 0);
        stack.scale(alpha, alpha, 1f);
        stack.translate(-screenW / 2f, -centerY, 0);

        float curX = startX;

        Fonts.SFP_BOLD.draw(stack, time, curX, centerY - TIME_SIZE / 2f - 0.5f,
                ColorUtil.getColor(210, (int)(225 * alpha)), TIME_SIZE);
        curX += timeW + GAP;

        float pillX = curX;
        RenderUtil.Shadow.drawShadow(stack, pillX - 3, startY - 3, pillW + 6, H + 6,
                8, alpha * 0.35f, ColorUtil.getColor(0));
        RenderUtil.Rounded.smooth(stack, pillX, startY, pillW, H,
                ColorUtil.getColor(28, 22, 38, (int)(218 * alpha)), Round.of(H / 2f));
        RenderUtil.Rounded.roundedOutline(stack, pillX, startY, pillW, H, 0.75f,
                ColorUtil.replAlpha(accent, alpha * 0.2f), Round.of(H / 2f));

        float innerX = pillX + PAD;

        float coverY = centerY - COVER_SIZE / 2f;
        RenderUtil.Rounded.smooth(stack, innerX, coverY, COVER_SIZE, COVER_SIZE,
                ColorUtil.replAlpha(accent, alpha * 0.32f), Round.of(COVER_SIZE / 3f));

        if (coverTexture != null) {
            mc.getTextureManager().bindTexture(coverTexture);
            RenderUtil.Texture.customRound(stack, innerX, coverY, COVER_SIZE, COVER_SIZE, alpha, 0, 0, 0, 0, Round.of(COVER_SIZE / 3f));
        } else {
            Fonts.ICON_DESHUX.draw(stack, "v",
                    innerX + COVER_SIZE / 2f - 3.5f, coverY + COVER_SIZE / 2f - 3.5f,
                    ColorUtil.replAlpha(accent, alpha * 0.75f), TEXT_SIZE);
        }

        innerX += COVER_SIZE + GAP;

        drawScrollText(stack, text, innerX, centerY - TEXT_SIZE / 2f - 0.5f, textW, TEXT_SIZE,
                ColorUtil.getColor(215, (int)(218 * alpha)));
        innerX += textW + GAP;

        float barW = 2.5f, barGap = 1.5f;
        float barBottom = centerY + 4f;
        if (playing) {
            for (int i = 0; i < 4; i++) {
                float bh = Math.max(1f, Math.min(barH[i] * (H / 11f), H - 4f));
                RenderUtil.Rounded.smooth(stack,
                        innerX + i * (barW + barGap), barBottom - bh,
                        barW, bh,
                        ColorUtil.replAlpha(accent, alpha * 0.85f), Round.of(barW / 2f));
            }
        } else {
            float pauseH = 8f, pauseW = 2f, pauseGap = 2f;
            float pauseX = innerX + (EQ_W - pauseW * 2 - pauseGap) / 2f;
            float pauseY = centerY - pauseH / 2f;
            RenderUtil.Rounded.smooth(stack, pauseX, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
            RenderUtil.Rounded.smooth(stack, pauseX + pauseW + pauseGap, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
        }

        curX = pillX + pillW + GAP;
        Fonts.ICON_DESHUX.draw(stack, "n", curX, centerY - (TEXT_SIZE + 0.5f) / 2f - 0.5f,
                ColorUtil.getColor(195, (int)(200 * alpha)), TEXT_SIZE + 0.5f);

        stack.pop();
    }

    private void drawScrollText(MatrixStack stack, String text, float x, float y,
                                float maxW, float fontSize, int color) {
        float textW = Fonts.SFP_MEDIUM.getWidth(text, fontSize);
        if (textW <= maxW) {
            Fonts.SFP_MEDIUM.draw(stack, text, x, y, color, fontSize);
            scroll = 0f;
            return;
        }

        long now = System.currentTimeMillis();
        float delta = (now - lastScroll) / 1000f;
        lastScroll = now;
        float speed = 20f, gap = 28f;
        scroll += delta * speed;
        if (scroll > textW + gap) scroll = 0f;

        double scale = mc.getMainWindow().getScaleFactor();
        int sx = (int)(x * scale);
        int sy = (int)(mc.getFramebuffer().framebufferHeight - (y + fontSize + 4) * scale);
        int sw = (int)(maxW * scale);
        int sh = (int)((fontSize + 6) * scale);

        GL11.glEnable(GL11.GL_SCISSOR_TEST);
        GL11.glScissor(sx, sy, sw, sh);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll, y, color, fontSize);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll + textW + gap, y, color, fontSize);
        GL11.glDisable(GL11.GL_SCISSOR_TEST);
    }
}
забыл упомянуть база excellent\night 1.1.3 кто сможет тот перенесет на другие
 
всем хай очередной завоз
щит гпт присутствует тк я не мог понять почему не идет музыка(если у вас открыто два потока музыки или видео то приоретет будет на тот который был запущен раннее)
ОБЯЗАТЕЛЬНО НУЖНА ЛИБКА БЕЗ НЕЕ НИЧЕГО НЕ РАБОТАЕТ -
Пожалуйста, авторизуйтесь для просмотра ссылки.

Закидывать либку в вашу папку с либками
сс -
Пожалуйста, авторизуйтесь для просмотра ссылки.
(смотреть со звуком)
код -
Java:
Expand Collapse Copy
import dev.kodek.client.api.events.orbit.EventHandler;
import dev.kodek.client.managers.events.render.Render2DEvent;
import dev.kodek.client.screen.InterFace;
import dev.kodek.client.screen.hud.IRenderer;
import dev.kodek.client.utils.animation.Animation;
import dev.kodek.client.utils.animation.util.Easings;
import dev.kodek.client.utils.render.color.ColorUtil;
import dev.kodek.client.utils.render.draw.RenderUtil;
import dev.kodek.client.utils.render.draw.Round;
import dev.kodek.client.utils.render.font.Fonts;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.util.ResourceLocation;
import net.mojang.blaze3d.matrix.MatrixStack;
import org.lwjgl.opengl.GL11;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class MusicBarRenderer implements IRenderer {

    private String song = null;
    private String artist = null;
    private boolean playing = false;
    private byte[] cover = null;
    private boolean coverLoaded = false;

    private ResourceLocation coverTexture = null;
    private static final ResourceLocation DEFAULT_COVER = new ResourceLocation("texture/Cat.png");

    private final float[] barH = {0f, 0f, 0f, 0f};
    private final float[] barTarget = {4f, 7f, 5f, 3f};
    private long lastWave = 0;

    private final Animation fade = new Animation();
    private final Animation bossAnim = new Animation();

    private float scroll = 0f;
    private long lastScroll = System.currentTimeMillis();

    private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(r -> {
        Thread t = new Thread(r, "music-thread");
        t.setDaemon(true);
        return t;
    });

    private static final float H = 18f;
    private static final float COVER_SIZE = 14f;
    private static final float TIME_SIZE = 8f;
    private static final float TEXT_SIZE = 6.5f;
    private static final float PAD = 5f;
    private static final float GAP = 7f;
    private static final float MAX_TEXT = 95f;
    private static final float EQ_W = 14f;
    private static final float BOSS_OFFSET = 28f;

    public MusicBarRenderer() {
        executor.scheduleAtFixedRate(this::fetchMusic, 0, 100, TimeUnit.MILLISECONDS);
        fade.set(0.0);
        bossAnim.set(0.0);
    }

    private void fetchMusic() {
        try {
            Class<?> mt = Class.forName("by.bonenaut7.mediatransport4j.api.MediaTransport");
            mt.getMethod("init").invoke(null);
            java.util.List<?> sessions = (java.util.List<?>) mt.getMethod("getMediaSessions").invoke(null);

            if (sessions != null && !sessions.isEmpty()) {
                Object active = null;
                for (Object s : sessions) {
                    boolean play = (Boolean) s.getClass().getMethod("isPlaying").invoke(s);
                    if (play) {
                        active = s;
                        break;
                    }
                }

                if (active == null) {
                    active = sessions.get(0);
                }

                String title = (String) active.getClass().getMethod("getTitle").invoke(active);
                String artistName = (String) active.getClass().getMethod("getArtist").invoke(active);
                boolean isPlaying = (Boolean) active.getClass().getMethod("isPlaying").invoke(active);

                song = title != null ? title : "Unknown";
                artist = artistName != null ? artistName : "Artist";
                playing = isPlaying;

                try {
                    Object thumb = active.getClass().getMethod("getThumbnail").invoke(active);
                    if (thumb instanceof BufferedImage) {
                        BufferedImage img = (BufferedImage) thumb;
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        ImageIO.write(img, "png", baos);
                        byte[] newCover = baos.toByteArray();

                        if (cover == null || !java.util.Arrays.equals(cover, newCover)) {
                            cover = newCover;
                            coverLoaded = false;
                        }
                    }
                } catch (NoSuchMethodException ignored) {}
            } else {
                song = null;
                cover = null;
                coverLoaded = false;
            }
        } catch (ClassNotFoundException ignored) {
            executor.shutdown();
        } catch (Exception ignored) {
            song = null;
        }
        updateBars();
    }

    private void loadCover() {
        if (coverLoaded) return;

        if (cover != null && cover.length > 0) {
            try {
                InputStream in = new ByteArrayInputStream(cover);
                BufferedImage img = ImageIO.read(in);
                if (img != null) {
                    int w = img.getWidth();
                    int h = img.getHeight();
                    NativeImage nativeImg = new NativeImage(w, h, false);

                    for (int x = 0; x < w; x++) {
                        for (int y = 0; y < h; y++) {
                            nativeImg.setPixelRGBA(x, y, img.getRGB(x, y));
                        }
                    }

                    DynamicTexture dynTex = new DynamicTexture(nativeImg);
                    coverTexture = mc.getTextureManager().getDynamicTextureLocation("music_cover_" + System.currentTimeMillis(), dynTex);
                    coverLoaded = true;
                    return;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        coverTexture = DEFAULT_COVER;
        coverLoaded = true;
    }

    private void updateBars() {
        if (playing) {
            if (System.currentTimeMillis() - lastWave > 95) {
                lastWave = System.currentTimeMillis();
                barTarget[0] = 3f + (float)(Math.random() * 7f);
                barTarget[1] = 2f + (float)(Math.random() * 10f);
                barTarget[2] = 4f + (float)(Math.random() * 5f);
                barTarget[3] = 3f + (float)(Math.random() * 6f);
            }
        } else {
            for (int i = 0; i < 4; i++) barTarget[i] = 0f;
        }
        for (int i = 0; i < 4; i++)
            barH[i] += (barTarget[i] - barH[i]) * 0.22f;
    }

    private boolean hasBoss() {
        return mc.ingameGUI.getBossOverlay().getMapBossInfos() != null &&
                !mc.ingameGUI.getBossOverlay().getMapBossInfos().isEmpty();
    }

    @Override
    @EventHandler
    public void render(Render2DEvent event) {
        if (song == null) {
            fade.run(0.0, 0.2, Easings.EXPO_IN, false);
            fade.update();
            bossAnim.update();
            return;
        }

        loadCover();

        bossAnim.update();
        boolean bossHere = hasBoss();
        bossAnim.run(bossHere ? 1.0 : 0.0, 0.25, Easings.EXPO_OUT, false);
        float bossShift = (float) bossAnim.get() * BOSS_OFFSET;

        fade.update();
        fade.run(1.0, 0.3, Easings.EXPO_OUT, false);
        float alpha = (float) fade.get();
        if (alpha < 0.02f) return;

        InterFace ui = InterFace.getInstance();
        MatrixStack stack = event.getMatrix();
        int accent = ui.themeColor();

        int screenW = mc.getMainWindow().getScaledWidth();

        String time = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm"));
        float timeW = Fonts.SFP_BOLD.getWidth(time, TIME_SIZE);

        String text = song + " - " + artist;
        float textW = Math.min(Fonts.SFP_MEDIUM.getWidth(text, TEXT_SIZE), MAX_TEXT);

        float wifiW = Fonts.ICON_DESHUX.getWidth("n", TEXT_SIZE + 0.5f);
        float pillW = PAD + COVER_SIZE + GAP + textW + GAP + EQ_W + PAD;
        float totalW = timeW + GAP + pillW + GAP + wifiW;

        float startX = (screenW - totalW) / 2f;
        float startY = 0f + bossShift;
        float centerY = startY + H / 2f;

        stack.push();
        stack.translate(screenW / 2f, centerY, 0);
        stack.scale(alpha, alpha, 1f);
        stack.translate(-screenW / 2f, -centerY, 0);

        float curX = startX;

        Fonts.SFP_BOLD.draw(stack, time, curX, centerY - TIME_SIZE / 2f - 0.5f,
                ColorUtil.getColor(210, (int)(225 * alpha)), TIME_SIZE);
        curX += timeW + GAP;

        float pillX = curX;
        RenderUtil.Shadow.drawShadow(stack, pillX - 3, startY - 3, pillW + 6, H + 6,
                8, alpha * 0.35f, ColorUtil.getColor(0));
        RenderUtil.Rounded.smooth(stack, pillX, startY, pillW, H,
                ColorUtil.getColor(28, 22, 38, (int)(218 * alpha)), Round.of(H / 2f));
        RenderUtil.Rounded.roundedOutline(stack, pillX, startY, pillW, H, 0.75f,
                ColorUtil.replAlpha(accent, alpha * 0.2f), Round.of(H / 2f));

        float innerX = pillX + PAD;

        float coverY = centerY - COVER_SIZE / 2f;
        RenderUtil.Rounded.smooth(stack, innerX, coverY, COVER_SIZE, COVER_SIZE,
                ColorUtil.replAlpha(accent, alpha * 0.32f), Round.of(COVER_SIZE / 3f));

        if (coverTexture != null) {
            mc.getTextureManager().bindTexture(coverTexture);
            RenderUtil.Texture.customRound(stack, innerX, coverY, COVER_SIZE, COVER_SIZE, alpha, 0, 0, 0, 0, Round.of(COVER_SIZE / 3f));
        } else {
            Fonts.ICON_DESHUX.draw(stack, "v",
                    innerX + COVER_SIZE / 2f - 3.5f, coverY + COVER_SIZE / 2f - 3.5f,
                    ColorUtil.replAlpha(accent, alpha * 0.75f), TEXT_SIZE);
        }

        innerX += COVER_SIZE + GAP;

        drawScrollText(stack, text, innerX, centerY - TEXT_SIZE / 2f - 0.5f, textW, TEXT_SIZE,
                ColorUtil.getColor(215, (int)(218 * alpha)));
        innerX += textW + GAP;

        float barW = 2.5f, barGap = 1.5f;
        float barBottom = centerY + 4f;
        if (playing) {
            for (int i = 0; i < 4; i++) {
                float bh = Math.max(1f, Math.min(barH[i] * (H / 11f), H - 4f));
                RenderUtil.Rounded.smooth(stack,
                        innerX + i * (barW + barGap), barBottom - bh,
                        barW, bh,
                        ColorUtil.replAlpha(accent, alpha * 0.85f), Round.of(barW / 2f));
            }
        } else {
            float pauseH = 8f, pauseW = 2f, pauseGap = 2f;
            float pauseX = innerX + (EQ_W - pauseW * 2 - pauseGap) / 2f;
            float pauseY = centerY - pauseH / 2f;
            RenderUtil.Rounded.smooth(stack, pauseX, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
            RenderUtil.Rounded.smooth(stack, pauseX + pauseW + pauseGap, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
        }

        curX = pillX + pillW + GAP;
        Fonts.ICON_DESHUX.draw(stack, "n", curX, centerY - (TEXT_SIZE + 0.5f) / 2f - 0.5f,
                ColorUtil.getColor(195, (int)(200 * alpha)), TEXT_SIZE + 0.5f);

        stack.pop();
    }

    private void drawScrollText(MatrixStack stack, String text, float x, float y,
                                float maxW, float fontSize, int color) {
        float textW = Fonts.SFP_MEDIUM.getWidth(text, fontSize);
        if (textW <= maxW) {
            Fonts.SFP_MEDIUM.draw(stack, text, x, y, color, fontSize);
            scroll = 0f;
            return;
        }

        long now = System.currentTimeMillis();
        float delta = (now - lastScroll) / 1000f;
        lastScroll = now;
        float speed = 20f, gap = 28f;
        scroll += delta * speed;
        if (scroll > textW + gap) scroll = 0f;

        double scale = mc.getMainWindow().getScaleFactor();
        int sx = (int)(x * scale);
        int sy = (int)(mc.getFramebuffer().framebufferHeight - (y + fontSize + 4) * scale);
        int sw = (int)(maxW * scale);
        int sh = (int)((fontSize + 6) * scale);

        GL11.glEnable(GL11.GL_SCISSOR_TEST);
        GL11.glScissor(sx, sy, sw, sh);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll, y, color, fontSize);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll + textW + gap, y, color, fontSize);
        GL11.glDisable(GL11.GL_SCISSOR_TEST);
    }
}

забыл упомянуть база excellent\night 1.1.3 кто сможет тот перенесет на другие
не юзабельно /del
 
всем хай очередной завоз
щит гпт присутствует тк я не мог понять почему не идет музыка(если у вас открыто два потока музыки или видео то приоретет будет на тот который был запущен раннее)
ОБЯЗАТЕЛЬНО НУЖНА ЛИБКА БЕЗ НЕЕ НИЧЕГО НЕ РАБОТАЕТ -
Пожалуйста, авторизуйтесь для просмотра ссылки.

Закидывать либку в вашу папку с либками
сс -
Пожалуйста, авторизуйтесь для просмотра ссылки.
(смотреть со звуком)
код -
Java:
Expand Collapse Copy
import dev.kodek.client.api.events.orbit.EventHandler;
import dev.kodek.client.managers.events.render.Render2DEvent;
import dev.kodek.client.screen.InterFace;
import dev.kodek.client.screen.hud.IRenderer;
import dev.kodek.client.utils.animation.Animation;
import dev.kodek.client.utils.animation.util.Easings;
import dev.kodek.client.utils.render.color.ColorUtil;
import dev.kodek.client.utils.render.draw.RenderUtil;
import dev.kodek.client.utils.render.draw.Round;
import dev.kodek.client.utils.render.font.Fonts;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.util.ResourceLocation;
import net.mojang.blaze3d.matrix.MatrixStack;
import org.lwjgl.opengl.GL11;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class MusicBarRenderer implements IRenderer {

    private String song = null;
    private String artist = null;
    private boolean playing = false;
    private byte[] cover = null;
    private boolean coverLoaded = false;

    private ResourceLocation coverTexture = null;
    private static final ResourceLocation DEFAULT_COVER = new ResourceLocation("texture/Cat.png");

    private final float[] barH = {0f, 0f, 0f, 0f};
    private final float[] barTarget = {4f, 7f, 5f, 3f};
    private long lastWave = 0;

    private final Animation fade = new Animation();
    private final Animation bossAnim = new Animation();

    private float scroll = 0f;
    private long lastScroll = System.currentTimeMillis();

    private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(r -> {
        Thread t = new Thread(r, "music-thread");
        t.setDaemon(true);
        return t;
    });

    private static final float H = 18f;
    private static final float COVER_SIZE = 14f;
    private static final float TIME_SIZE = 8f;
    private static final float TEXT_SIZE = 6.5f;
    private static final float PAD = 5f;
    private static final float GAP = 7f;
    private static final float MAX_TEXT = 95f;
    private static final float EQ_W = 14f;
    private static final float BOSS_OFFSET = 28f;

    public MusicBarRenderer() {
        executor.scheduleAtFixedRate(this::fetchMusic, 0, 100, TimeUnit.MILLISECONDS);
        fade.set(0.0);
        bossAnim.set(0.0);
    }

    private void fetchMusic() {
        try {
            Class<?> mt = Class.forName("by.bonenaut7.mediatransport4j.api.MediaTransport");
            mt.getMethod("init").invoke(null);
            java.util.List<?> sessions = (java.util.List<?>) mt.getMethod("getMediaSessions").invoke(null);

            if (sessions != null && !sessions.isEmpty()) {
                Object active = null;
                for (Object s : sessions) {
                    boolean play = (Boolean) s.getClass().getMethod("isPlaying").invoke(s);
                    if (play) {
                        active = s;
                        break;
                    }
                }

                if (active == null) {
                    active = sessions.get(0);
                }

                String title = (String) active.getClass().getMethod("getTitle").invoke(active);
                String artistName = (String) active.getClass().getMethod("getArtist").invoke(active);
                boolean isPlaying = (Boolean) active.getClass().getMethod("isPlaying").invoke(active);

                song = title != null ? title : "Unknown";
                artist = artistName != null ? artistName : "Artist";
                playing = isPlaying;

                try {
                    Object thumb = active.getClass().getMethod("getThumbnail").invoke(active);
                    if (thumb instanceof BufferedImage) {
                        BufferedImage img = (BufferedImage) thumb;
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        ImageIO.write(img, "png", baos);
                        byte[] newCover = baos.toByteArray();

                        if (cover == null || !java.util.Arrays.equals(cover, newCover)) {
                            cover = newCover;
                            coverLoaded = false;
                        }
                    }
                } catch (NoSuchMethodException ignored) {}
            } else {
                song = null;
                cover = null;
                coverLoaded = false;
            }
        } catch (ClassNotFoundException ignored) {
            executor.shutdown();
        } catch (Exception ignored) {
            song = null;
        }
        updateBars();
    }

    private void loadCover() {
        if (coverLoaded) return;

        if (cover != null && cover.length > 0) {
            try {
                InputStream in = new ByteArrayInputStream(cover);
                BufferedImage img = ImageIO.read(in);
                if (img != null) {
                    int w = img.getWidth();
                    int h = img.getHeight();
                    NativeImage nativeImg = new NativeImage(w, h, false);

                    for (int x = 0; x < w; x++) {
                        for (int y = 0; y < h; y++) {
                            nativeImg.setPixelRGBA(x, y, img.getRGB(x, y));
                        }
                    }

                    DynamicTexture dynTex = new DynamicTexture(nativeImg);
                    coverTexture = mc.getTextureManager().getDynamicTextureLocation("music_cover_" + System.currentTimeMillis(), dynTex);
                    coverLoaded = true;
                    return;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        coverTexture = DEFAULT_COVER;
        coverLoaded = true;
    }

    private void updateBars() {
        if (playing) {
            if (System.currentTimeMillis() - lastWave > 95) {
                lastWave = System.currentTimeMillis();
                barTarget[0] = 3f + (float)(Math.random() * 7f);
                barTarget[1] = 2f + (float)(Math.random() * 10f);
                barTarget[2] = 4f + (float)(Math.random() * 5f);
                barTarget[3] = 3f + (float)(Math.random() * 6f);
            }
        } else {
            for (int i = 0; i < 4; i++) barTarget[i] = 0f;
        }
        for (int i = 0; i < 4; i++)
            barH[i] += (barTarget[i] - barH[i]) * 0.22f;
    }

    private boolean hasBoss() {
        return mc.ingameGUI.getBossOverlay().getMapBossInfos() != null &&
                !mc.ingameGUI.getBossOverlay().getMapBossInfos().isEmpty();
    }

    @Override
    @EventHandler
    public void render(Render2DEvent event) {
        if (song == null) {
            fade.run(0.0, 0.2, Easings.EXPO_IN, false);
            fade.update();
            bossAnim.update();
            return;
        }

        loadCover();

        bossAnim.update();
        boolean bossHere = hasBoss();
        bossAnim.run(bossHere ? 1.0 : 0.0, 0.25, Easings.EXPO_OUT, false);
        float bossShift = (float) bossAnim.get() * BOSS_OFFSET;

        fade.update();
        fade.run(1.0, 0.3, Easings.EXPO_OUT, false);
        float alpha = (float) fade.get();
        if (alpha < 0.02f) return;

        InterFace ui = InterFace.getInstance();
        MatrixStack stack = event.getMatrix();
        int accent = ui.themeColor();

        int screenW = mc.getMainWindow().getScaledWidth();

        String time = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm"));
        float timeW = Fonts.SFP_BOLD.getWidth(time, TIME_SIZE);

        String text = song + " - " + artist;
        float textW = Math.min(Fonts.SFP_MEDIUM.getWidth(text, TEXT_SIZE), MAX_TEXT);

        float wifiW = Fonts.ICON_DESHUX.getWidth("n", TEXT_SIZE + 0.5f);
        float pillW = PAD + COVER_SIZE + GAP + textW + GAP + EQ_W + PAD;
        float totalW = timeW + GAP + pillW + GAP + wifiW;

        float startX = (screenW - totalW) / 2f;
        float startY = 0f + bossShift;
        float centerY = startY + H / 2f;

        stack.push();
        stack.translate(screenW / 2f, centerY, 0);
        stack.scale(alpha, alpha, 1f);
        stack.translate(-screenW / 2f, -centerY, 0);

        float curX = startX;

        Fonts.SFP_BOLD.draw(stack, time, curX, centerY - TIME_SIZE / 2f - 0.5f,
                ColorUtil.getColor(210, (int)(225 * alpha)), TIME_SIZE);
        curX += timeW + GAP;

        float pillX = curX;
        RenderUtil.Shadow.drawShadow(stack, pillX - 3, startY - 3, pillW + 6, H + 6,
                8, alpha * 0.35f, ColorUtil.getColor(0));
        RenderUtil.Rounded.smooth(stack, pillX, startY, pillW, H,
                ColorUtil.getColor(28, 22, 38, (int)(218 * alpha)), Round.of(H / 2f));
        RenderUtil.Rounded.roundedOutline(stack, pillX, startY, pillW, H, 0.75f,
                ColorUtil.replAlpha(accent, alpha * 0.2f), Round.of(H / 2f));

        float innerX = pillX + PAD;

        float coverY = centerY - COVER_SIZE / 2f;
        RenderUtil.Rounded.smooth(stack, innerX, coverY, COVER_SIZE, COVER_SIZE,
                ColorUtil.replAlpha(accent, alpha * 0.32f), Round.of(COVER_SIZE / 3f));

        if (coverTexture != null) {
            mc.getTextureManager().bindTexture(coverTexture);
            RenderUtil.Texture.customRound(stack, innerX, coverY, COVER_SIZE, COVER_SIZE, alpha, 0, 0, 0, 0, Round.of(COVER_SIZE / 3f));
        } else {
            Fonts.ICON_DESHUX.draw(stack, "v",
                    innerX + COVER_SIZE / 2f - 3.5f, coverY + COVER_SIZE / 2f - 3.5f,
                    ColorUtil.replAlpha(accent, alpha * 0.75f), TEXT_SIZE);
        }

        innerX += COVER_SIZE + GAP;

        drawScrollText(stack, text, innerX, centerY - TEXT_SIZE / 2f - 0.5f, textW, TEXT_SIZE,
                ColorUtil.getColor(215, (int)(218 * alpha)));
        innerX += textW + GAP;

        float barW = 2.5f, barGap = 1.5f;
        float barBottom = centerY + 4f;
        if (playing) {
            for (int i = 0; i < 4; i++) {
                float bh = Math.max(1f, Math.min(barH[i] * (H / 11f), H - 4f));
                RenderUtil.Rounded.smooth(stack,
                        innerX + i * (barW + barGap), barBottom - bh,
                        barW, bh,
                        ColorUtil.replAlpha(accent, alpha * 0.85f), Round.of(barW / 2f));
            }
        } else {
            float pauseH = 8f, pauseW = 2f, pauseGap = 2f;
            float pauseX = innerX + (EQ_W - pauseW * 2 - pauseGap) / 2f;
            float pauseY = centerY - pauseH / 2f;
            RenderUtil.Rounded.smooth(stack, pauseX, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
            RenderUtil.Rounded.smooth(stack, pauseX + pauseW + pauseGap, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
        }

        curX = pillX + pillW + GAP;
        Fonts.ICON_DESHUX.draw(stack, "n", curX, centerY - (TEXT_SIZE + 0.5f) / 2f - 0.5f,
                ColorUtil.getColor(195, (int)(200 * alpha)), TEXT_SIZE + 0.5f);

        stack.pop();
    }

    private void drawScrollText(MatrixStack stack, String text, float x, float y,
                                float maxW, float fontSize, int color) {
        float textW = Fonts.SFP_MEDIUM.getWidth(text, fontSize);
        if (textW <= maxW) {
            Fonts.SFP_MEDIUM.draw(stack, text, x, y, color, fontSize);
            scroll = 0f;
            return;
        }

        long now = System.currentTimeMillis();
        float delta = (now - lastScroll) / 1000f;
        lastScroll = now;
        float speed = 20f, gap = 28f;
        scroll += delta * speed;
        if (scroll > textW + gap) scroll = 0f;

        double scale = mc.getMainWindow().getScaleFactor();
        int sx = (int)(x * scale);
        int sy = (int)(mc.getFramebuffer().framebufferHeight - (y + fontSize + 4) * scale);
        int sw = (int)(maxW * scale);
        int sh = (int)((fontSize + 6) * scale);

        GL11.glEnable(GL11.GL_SCISSOR_TEST);
        GL11.glScissor(sx, sy, sw, sh);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll, y, color, fontSize);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll + textW + gap, y, color, fontSize);
        GL11.glDisable(GL11.GL_SCISSOR_TEST);
    }
}

забыл упомянуть база excellent\night 1.1.3 кто сможет тот перенесет на другие
хм выглядит достаточно не плохо но все равно есть что нужно пофиксить.
 
всем хай очередной завоз
щит гпт присутствует тк я не мог понять почему не идет музыка(если у вас открыто два потока музыки или видео то приоретет будет на тот который был запущен раннее)
ОБЯЗАТЕЛЬНО НУЖНА ЛИБКА БЕЗ НЕЕ НИЧЕГО НЕ РАБОТАЕТ -
Пожалуйста, авторизуйтесь для просмотра ссылки.

Закидывать либку в вашу папку с либками
сс -
Пожалуйста, авторизуйтесь для просмотра ссылки.
(смотреть со звуком)
код -
Java:
Expand Collapse Copy
import dev.kodek.client.api.events.orbit.EventHandler;
import dev.kodek.client.managers.events.render.Render2DEvent;
import dev.kodek.client.screen.InterFace;
import dev.kodek.client.screen.hud.IRenderer;
import dev.kodek.client.utils.animation.Animation;
import dev.kodek.client.utils.animation.util.Easings;
import dev.kodek.client.utils.render.color.ColorUtil;
import dev.kodek.client.utils.render.draw.RenderUtil;
import dev.kodek.client.utils.render.draw.Round;
import dev.kodek.client.utils.render.font.Fonts;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.util.ResourceLocation;
import net.mojang.blaze3d.matrix.MatrixStack;
import org.lwjgl.opengl.GL11;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class MusicBarRenderer implements IRenderer {

    private String song = null;
    private String artist = null;
    private boolean playing = false;
    private byte[] cover = null;
    private boolean coverLoaded = false;

    private ResourceLocation coverTexture = null;
    private static final ResourceLocation DEFAULT_COVER = new ResourceLocation("texture/Cat.png");

    private final float[] barH = {0f, 0f, 0f, 0f};
    private final float[] barTarget = {4f, 7f, 5f, 3f};
    private long lastWave = 0;

    private final Animation fade = new Animation();
    private final Animation bossAnim = new Animation();

    private float scroll = 0f;
    private long lastScroll = System.currentTimeMillis();

    private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(r -> {
        Thread t = new Thread(r, "music-thread");
        t.setDaemon(true);
        return t;
    });

    private static final float H = 18f;
    private static final float COVER_SIZE = 14f;
    private static final float TIME_SIZE = 8f;
    private static final float TEXT_SIZE = 6.5f;
    private static final float PAD = 5f;
    private static final float GAP = 7f;
    private static final float MAX_TEXT = 95f;
    private static final float EQ_W = 14f;
    private static final float BOSS_OFFSET = 28f;

    public MusicBarRenderer() {
        executor.scheduleAtFixedRate(this::fetchMusic, 0, 100, TimeUnit.MILLISECONDS);
        fade.set(0.0);
        bossAnim.set(0.0);
    }

    private void fetchMusic() {
        try {
            Class<?> mt = Class.forName("by.bonenaut7.mediatransport4j.api.MediaTransport");
            mt.getMethod("init").invoke(null);
            java.util.List<?> sessions = (java.util.List<?>) mt.getMethod("getMediaSessions").invoke(null);

            if (sessions != null && !sessions.isEmpty()) {
                Object active = null;
                for (Object s : sessions) {
                    boolean play = (Boolean) s.getClass().getMethod("isPlaying").invoke(s);
                    if (play) {
                        active = s;
                        break;
                    }
                }

                if (active == null) {
                    active = sessions.get(0);
                }

                String title = (String) active.getClass().getMethod("getTitle").invoke(active);
                String artistName = (String) active.getClass().getMethod("getArtist").invoke(active);
                boolean isPlaying = (Boolean) active.getClass().getMethod("isPlaying").invoke(active);

                song = title != null ? title : "Unknown";
                artist = artistName != null ? artistName : "Artist";
                playing = isPlaying;

                try {
                    Object thumb = active.getClass().getMethod("getThumbnail").invoke(active);
                    if (thumb instanceof BufferedImage) {
                        BufferedImage img = (BufferedImage) thumb;
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        ImageIO.write(img, "png", baos);
                        byte[] newCover = baos.toByteArray();

                        if (cover == null || !java.util.Arrays.equals(cover, newCover)) {
                            cover = newCover;
                            coverLoaded = false;
                        }
                    }
                } catch (NoSuchMethodException ignored) {}
            } else {
                song = null;
                cover = null;
                coverLoaded = false;
            }
        } catch (ClassNotFoundException ignored) {
            executor.shutdown();
        } catch (Exception ignored) {
            song = null;
        }
        updateBars();
    }

    private void loadCover() {
        if (coverLoaded) return;

        if (cover != null && cover.length > 0) {
            try {
                InputStream in = new ByteArrayInputStream(cover);
                BufferedImage img = ImageIO.read(in);
                if (img != null) {
                    int w = img.getWidth();
                    int h = img.getHeight();
                    NativeImage nativeImg = new NativeImage(w, h, false);

                    for (int x = 0; x < w; x++) {
                        for (int y = 0; y < h; y++) {
                            nativeImg.setPixelRGBA(x, y, img.getRGB(x, y));
                        }
                    }

                    DynamicTexture dynTex = new DynamicTexture(nativeImg);
                    coverTexture = mc.getTextureManager().getDynamicTextureLocation("music_cover_" + System.currentTimeMillis(), dynTex);
                    coverLoaded = true;
                    return;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        coverTexture = DEFAULT_COVER;
        coverLoaded = true;
    }

    private void updateBars() {
        if (playing) {
            if (System.currentTimeMillis() - lastWave > 95) {
                lastWave = System.currentTimeMillis();
                barTarget[0] = 3f + (float)(Math.random() * 7f);
                barTarget[1] = 2f + (float)(Math.random() * 10f);
                barTarget[2] = 4f + (float)(Math.random() * 5f);
                barTarget[3] = 3f + (float)(Math.random() * 6f);
            }
        } else {
            for (int i = 0; i < 4; i++) barTarget[i] = 0f;
        }
        for (int i = 0; i < 4; i++)
            barH[i] += (barTarget[i] - barH[i]) * 0.22f;
    }

    private boolean hasBoss() {
        return mc.ingameGUI.getBossOverlay().getMapBossInfos() != null &&
                !mc.ingameGUI.getBossOverlay().getMapBossInfos().isEmpty();
    }

    @Override
    @EventHandler
    public void render(Render2DEvent event) {
        if (song == null) {
            fade.run(0.0, 0.2, Easings.EXPO_IN, false);
            fade.update();
            bossAnim.update();
            return;
        }

        loadCover();

        bossAnim.update();
        boolean bossHere = hasBoss();
        bossAnim.run(bossHere ? 1.0 : 0.0, 0.25, Easings.EXPO_OUT, false);
        float bossShift = (float) bossAnim.get() * BOSS_OFFSET;

        fade.update();
        fade.run(1.0, 0.3, Easings.EXPO_OUT, false);
        float alpha = (float) fade.get();
        if (alpha < 0.02f) return;

        InterFace ui = InterFace.getInstance();
        MatrixStack stack = event.getMatrix();
        int accent = ui.themeColor();

        int screenW = mc.getMainWindow().getScaledWidth();

        String time = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm"));
        float timeW = Fonts.SFP_BOLD.getWidth(time, TIME_SIZE);

        String text = song + " - " + artist;
        float textW = Math.min(Fonts.SFP_MEDIUM.getWidth(text, TEXT_SIZE), MAX_TEXT);

        float wifiW = Fonts.ICON_DESHUX.getWidth("n", TEXT_SIZE + 0.5f);
        float pillW = PAD + COVER_SIZE + GAP + textW + GAP + EQ_W + PAD;
        float totalW = timeW + GAP + pillW + GAP + wifiW;

        float startX = (screenW - totalW) / 2f;
        float startY = 0f + bossShift;
        float centerY = startY + H / 2f;

        stack.push();
        stack.translate(screenW / 2f, centerY, 0);
        stack.scale(alpha, alpha, 1f);
        stack.translate(-screenW / 2f, -centerY, 0);

        float curX = startX;

        Fonts.SFP_BOLD.draw(stack, time, curX, centerY - TIME_SIZE / 2f - 0.5f,
                ColorUtil.getColor(210, (int)(225 * alpha)), TIME_SIZE);
        curX += timeW + GAP;

        float pillX = curX;
        RenderUtil.Shadow.drawShadow(stack, pillX - 3, startY - 3, pillW + 6, H + 6,
                8, alpha * 0.35f, ColorUtil.getColor(0));
        RenderUtil.Rounded.smooth(stack, pillX, startY, pillW, H,
                ColorUtil.getColor(28, 22, 38, (int)(218 * alpha)), Round.of(H / 2f));
        RenderUtil.Rounded.roundedOutline(stack, pillX, startY, pillW, H, 0.75f,
                ColorUtil.replAlpha(accent, alpha * 0.2f), Round.of(H / 2f));

        float innerX = pillX + PAD;

        float coverY = centerY - COVER_SIZE / 2f;
        RenderUtil.Rounded.smooth(stack, innerX, coverY, COVER_SIZE, COVER_SIZE,
                ColorUtil.replAlpha(accent, alpha * 0.32f), Round.of(COVER_SIZE / 3f));

        if (coverTexture != null) {
            mc.getTextureManager().bindTexture(coverTexture);
            RenderUtil.Texture.customRound(stack, innerX, coverY, COVER_SIZE, COVER_SIZE, alpha, 0, 0, 0, 0, Round.of(COVER_SIZE / 3f));
        } else {
            Fonts.ICON_DESHUX.draw(stack, "v",
                    innerX + COVER_SIZE / 2f - 3.5f, coverY + COVER_SIZE / 2f - 3.5f,
                    ColorUtil.replAlpha(accent, alpha * 0.75f), TEXT_SIZE);
        }

        innerX += COVER_SIZE + GAP;

        drawScrollText(stack, text, innerX, centerY - TEXT_SIZE / 2f - 0.5f, textW, TEXT_SIZE,
                ColorUtil.getColor(215, (int)(218 * alpha)));
        innerX += textW + GAP;

        float barW = 2.5f, barGap = 1.5f;
        float barBottom = centerY + 4f;
        if (playing) {
            for (int i = 0; i < 4; i++) {
                float bh = Math.max(1f, Math.min(barH[i] * (H / 11f), H - 4f));
                RenderUtil.Rounded.smooth(stack,
                        innerX + i * (barW + barGap), barBottom - bh,
                        barW, bh,
                        ColorUtil.replAlpha(accent, alpha * 0.85f), Round.of(barW / 2f));
            }
        } else {
            float pauseH = 8f, pauseW = 2f, pauseGap = 2f;
            float pauseX = innerX + (EQ_W - pauseW * 2 - pauseGap) / 2f;
            float pauseY = centerY - pauseH / 2f;
            RenderUtil.Rounded.smooth(stack, pauseX, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
            RenderUtil.Rounded.smooth(stack, pauseX + pauseW + pauseGap, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
        }

        curX = pillX + pillW + GAP;
        Fonts.ICON_DESHUX.draw(stack, "n", curX, centerY - (TEXT_SIZE + 0.5f) / 2f - 0.5f,
                ColorUtil.getColor(195, (int)(200 * alpha)), TEXT_SIZE + 0.5f);

        stack.pop();
    }

    private void drawScrollText(MatrixStack stack, String text, float x, float y,
                                float maxW, float fontSize, int color) {
        float textW = Fonts.SFP_MEDIUM.getWidth(text, fontSize);
        if (textW <= maxW) {
            Fonts.SFP_MEDIUM.draw(stack, text, x, y, color, fontSize);
            scroll = 0f;
            return;
        }

        long now = System.currentTimeMillis();
        float delta = (now - lastScroll) / 1000f;
        lastScroll = now;
        float speed = 20f, gap = 28f;
        scroll += delta * speed;
        if (scroll > textW + gap) scroll = 0f;

        double scale = mc.getMainWindow().getScaleFactor();
        int sx = (int)(x * scale);
        int sy = (int)(mc.getFramebuffer().framebufferHeight - (y + fontSize + 4) * scale);
        int sw = (int)(maxW * scale);
        int sh = (int)((fontSize + 6) * scale);

        GL11.glEnable(GL11.GL_SCISSOR_TEST);
        GL11.glScissor(sx, sy, sw, sh);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll, y, color, fontSize);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll + textW + gap, y, color, fontSize);
        GL11.glDisable(GL11.GL_SCISSOR_TEST);
    }
}

забыл упомянуть база excellent\night 1.1.3 кто сможет тот перенесет на другие
мы с тобой на одной базе я сделал все сделал сеттинг в интерфейсе не показывает чет мб в сеттингах чет сделал? буду рад если свои скинешь
 
всем хай очередной завоз
щит гпт присутствует тк я не мог понять почему не идет музыка(если у вас открыто два потока музыки или видео то приоретет будет на тот который был запущен раннее)
ОБЯЗАТЕЛЬНО НУЖНА ЛИБКА БЕЗ НЕЕ НИЧЕГО НЕ РАБОТАЕТ -
Пожалуйста, авторизуйтесь для просмотра ссылки.

Закидывать либку в вашу папку с либками
сс -
Пожалуйста, авторизуйтесь для просмотра ссылки.
(смотреть со звуком)
код -
Java:
Expand Collapse Copy
import dev.kodek.client.api.events.orbit.EventHandler;
import dev.kodek.client.managers.events.render.Render2DEvent;
import dev.kodek.client.screen.InterFace;
import dev.kodek.client.screen.hud.IRenderer;
import dev.kodek.client.utils.animation.Animation;
import dev.kodek.client.utils.animation.util.Easings;
import dev.kodek.client.utils.render.color.ColorUtil;
import dev.kodek.client.utils.render.draw.RenderUtil;
import dev.kodek.client.utils.render.draw.Round;
import dev.kodek.client.utils.render.font.Fonts;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.util.ResourceLocation;
import net.mojang.blaze3d.matrix.MatrixStack;
import org.lwjgl.opengl.GL11;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class MusicBarRenderer implements IRenderer {

    private String song = null;
    private String artist = null;
    private boolean playing = false;
    private byte[] cover = null;
    private boolean coverLoaded = false;

    private ResourceLocation coverTexture = null;
    private static final ResourceLocation DEFAULT_COVER = new ResourceLocation("texture/Cat.png");

    private final float[] barH = {0f, 0f, 0f, 0f};
    private final float[] barTarget = {4f, 7f, 5f, 3f};
    private long lastWave = 0;

    private final Animation fade = new Animation();
    private final Animation bossAnim = new Animation();

    private float scroll = 0f;
    private long lastScroll = System.currentTimeMillis();

    private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(r -> {
        Thread t = new Thread(r, "music-thread");
        t.setDaemon(true);
        return t;
    });

    private static final float H = 18f;
    private static final float COVER_SIZE = 14f;
    private static final float TIME_SIZE = 8f;
    private static final float TEXT_SIZE = 6.5f;
    private static final float PAD = 5f;
    private static final float GAP = 7f;
    private static final float MAX_TEXT = 95f;
    private static final float EQ_W = 14f;
    private static final float BOSS_OFFSET = 28f;

    public MusicBarRenderer() {
        executor.scheduleAtFixedRate(this::fetchMusic, 0, 100, TimeUnit.MILLISECONDS);
        fade.set(0.0);
        bossAnim.set(0.0);
    }

    private void fetchMusic() {
        try {
            Class<?> mt = Class.forName("by.bonenaut7.mediatransport4j.api.MediaTransport");
            mt.getMethod("init").invoke(null);
            java.util.List<?> sessions = (java.util.List<?>) mt.getMethod("getMediaSessions").invoke(null);

            if (sessions != null && !sessions.isEmpty()) {
                Object active = null;
                for (Object s : sessions) {
                    boolean play = (Boolean) s.getClass().getMethod("isPlaying").invoke(s);
                    if (play) {
                        active = s;
                        break;
                    }
                }

                if (active == null) {
                    active = sessions.get(0);
                }

                String title = (String) active.getClass().getMethod("getTitle").invoke(active);
                String artistName = (String) active.getClass().getMethod("getArtist").invoke(active);
                boolean isPlaying = (Boolean) active.getClass().getMethod("isPlaying").invoke(active);

                song = title != null ? title : "Unknown";
                artist = artistName != null ? artistName : "Artist";
                playing = isPlaying;

                try {
                    Object thumb = active.getClass().getMethod("getThumbnail").invoke(active);
                    if (thumb instanceof BufferedImage) {
                        BufferedImage img = (BufferedImage) thumb;
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        ImageIO.write(img, "png", baos);
                        byte[] newCover = baos.toByteArray();

                        if (cover == null || !java.util.Arrays.equals(cover, newCover)) {
                            cover = newCover;
                            coverLoaded = false;
                        }
                    }
                } catch (NoSuchMethodException ignored) {}
            } else {
                song = null;
                cover = null;
                coverLoaded = false;
            }
        } catch (ClassNotFoundException ignored) {
            executor.shutdown();
        } catch (Exception ignored) {
            song = null;
        }
        updateBars();
    }

    private void loadCover() {
        if (coverLoaded) return;

        if (cover != null && cover.length > 0) {
            try {
                InputStream in = new ByteArrayInputStream(cover);
                BufferedImage img = ImageIO.read(in);
                if (img != null) {
                    int w = img.getWidth();
                    int h = img.getHeight();
                    NativeImage nativeImg = new NativeImage(w, h, false);

                    for (int x = 0; x < w; x++) {
                        for (int y = 0; y < h; y++) {
                            nativeImg.setPixelRGBA(x, y, img.getRGB(x, y));
                        }
                    }

                    DynamicTexture dynTex = new DynamicTexture(nativeImg);
                    coverTexture = mc.getTextureManager().getDynamicTextureLocation("music_cover_" + System.currentTimeMillis(), dynTex);
                    coverLoaded = true;
                    return;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        coverTexture = DEFAULT_COVER;
        coverLoaded = true;
    }

    private void updateBars() {
        if (playing) {
            if (System.currentTimeMillis() - lastWave > 95) {
                lastWave = System.currentTimeMillis();
                barTarget[0] = 3f + (float)(Math.random() * 7f);
                barTarget[1] = 2f + (float)(Math.random() * 10f);
                barTarget[2] = 4f + (float)(Math.random() * 5f);
                barTarget[3] = 3f + (float)(Math.random() * 6f);
            }
        } else {
            for (int i = 0; i < 4; i++) barTarget[i] = 0f;
        }
        for (int i = 0; i < 4; i++)
            barH[i] += (barTarget[i] - barH[i]) * 0.22f;
    }

    private boolean hasBoss() {
        return mc.ingameGUI.getBossOverlay().getMapBossInfos() != null &&
                !mc.ingameGUI.getBossOverlay().getMapBossInfos().isEmpty();
    }

    @Override
    @EventHandler
    public void render(Render2DEvent event) {
        if (song == null) {
            fade.run(0.0, 0.2, Easings.EXPO_IN, false);
            fade.update();
            bossAnim.update();
            return;
        }

        loadCover();

        bossAnim.update();
        boolean bossHere = hasBoss();
        bossAnim.run(bossHere ? 1.0 : 0.0, 0.25, Easings.EXPO_OUT, false);
        float bossShift = (float) bossAnim.get() * BOSS_OFFSET;

        fade.update();
        fade.run(1.0, 0.3, Easings.EXPO_OUT, false);
        float alpha = (float) fade.get();
        if (alpha < 0.02f) return;

        InterFace ui = InterFace.getInstance();
        MatrixStack stack = event.getMatrix();
        int accent = ui.themeColor();

        int screenW = mc.getMainWindow().getScaledWidth();

        String time = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm"));
        float timeW = Fonts.SFP_BOLD.getWidth(time, TIME_SIZE);

        String text = song + " - " + artist;
        float textW = Math.min(Fonts.SFP_MEDIUM.getWidth(text, TEXT_SIZE), MAX_TEXT);

        float wifiW = Fonts.ICON_DESHUX.getWidth("n", TEXT_SIZE + 0.5f);
        float pillW = PAD + COVER_SIZE + GAP + textW + GAP + EQ_W + PAD;
        float totalW = timeW + GAP + pillW + GAP + wifiW;

        float startX = (screenW - totalW) / 2f;
        float startY = 0f + bossShift;
        float centerY = startY + H / 2f;

        stack.push();
        stack.translate(screenW / 2f, centerY, 0);
        stack.scale(alpha, alpha, 1f);
        stack.translate(-screenW / 2f, -centerY, 0);

        float curX = startX;

        Fonts.SFP_BOLD.draw(stack, time, curX, centerY - TIME_SIZE / 2f - 0.5f,
                ColorUtil.getColor(210, (int)(225 * alpha)), TIME_SIZE);
        curX += timeW + GAP;

        float pillX = curX;
        RenderUtil.Shadow.drawShadow(stack, pillX - 3, startY - 3, pillW + 6, H + 6,
                8, alpha * 0.35f, ColorUtil.getColor(0));
        RenderUtil.Rounded.smooth(stack, pillX, startY, pillW, H,
                ColorUtil.getColor(28, 22, 38, (int)(218 * alpha)), Round.of(H / 2f));
        RenderUtil.Rounded.roundedOutline(stack, pillX, startY, pillW, H, 0.75f,
                ColorUtil.replAlpha(accent, alpha * 0.2f), Round.of(H / 2f));

        float innerX = pillX + PAD;

        float coverY = centerY - COVER_SIZE / 2f;
        RenderUtil.Rounded.smooth(stack, innerX, coverY, COVER_SIZE, COVER_SIZE,
                ColorUtil.replAlpha(accent, alpha * 0.32f), Round.of(COVER_SIZE / 3f));

        if (coverTexture != null) {
            mc.getTextureManager().bindTexture(coverTexture);
            RenderUtil.Texture.customRound(stack, innerX, coverY, COVER_SIZE, COVER_SIZE, alpha, 0, 0, 0, 0, Round.of(COVER_SIZE / 3f));
        } else {
            Fonts.ICON_DESHUX.draw(stack, "v",
                    innerX + COVER_SIZE / 2f - 3.5f, coverY + COVER_SIZE / 2f - 3.5f,
                    ColorUtil.replAlpha(accent, alpha * 0.75f), TEXT_SIZE);
        }

        innerX += COVER_SIZE + GAP;

        drawScrollText(stack, text, innerX, centerY - TEXT_SIZE / 2f - 0.5f, textW, TEXT_SIZE,
                ColorUtil.getColor(215, (int)(218 * alpha)));
        innerX += textW + GAP;

        float barW = 2.5f, barGap = 1.5f;
        float barBottom = centerY + 4f;
        if (playing) {
            for (int i = 0; i < 4; i++) {
                float bh = Math.max(1f, Math.min(barH[i] * (H / 11f), H - 4f));
                RenderUtil.Rounded.smooth(stack,
                        innerX + i * (barW + barGap), barBottom - bh,
                        barW, bh,
                        ColorUtil.replAlpha(accent, alpha * 0.85f), Round.of(barW / 2f));
            }
        } else {
            float pauseH = 8f, pauseW = 2f, pauseGap = 2f;
            float pauseX = innerX + (EQ_W - pauseW * 2 - pauseGap) / 2f;
            float pauseY = centerY - pauseH / 2f;
            RenderUtil.Rounded.smooth(stack, pauseX, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
            RenderUtil.Rounded.smooth(stack, pauseX + pauseW + pauseGap, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
        }

        curX = pillX + pillW + GAP;
        Fonts.ICON_DESHUX.draw(stack, "n", curX, centerY - (TEXT_SIZE + 0.5f) / 2f - 0.5f,
                ColorUtil.getColor(195, (int)(200 * alpha)), TEXT_SIZE + 0.5f);

        stack.pop();
    }

    private void drawScrollText(MatrixStack stack, String text, float x, float y,
                                float maxW, float fontSize, int color) {
        float textW = Fonts.SFP_MEDIUM.getWidth(text, fontSize);
        if (textW <= maxW) {
            Fonts.SFP_MEDIUM.draw(stack, text, x, y, color, fontSize);
            scroll = 0f;
            return;
        }

        long now = System.currentTimeMillis();
        float delta = (now - lastScroll) / 1000f;
        lastScroll = now;
        float speed = 20f, gap = 28f;
        scroll += delta * speed;
        if (scroll > textW + gap) scroll = 0f;

        double scale = mc.getMainWindow().getScaleFactor();
        int sx = (int)(x * scale);
        int sy = (int)(mc.getFramebuffer().framebufferHeight - (y + fontSize + 4) * scale);
        int sw = (int)(maxW * scale);
        int sh = (int)((fontSize + 6) * scale);

        GL11.glEnable(GL11.GL_SCISSOR_TEST);
        GL11.glScissor(sx, sy, sw, sh);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll, y, color, fontSize);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll + textW + gap, y, color, fontSize);
        GL11.glDisable(GL11.GL_SCISSOR_TEST);
    }
}

забыл упомянуть база excellent\night 1.1.3 кто сможет тот перенесет на другие
/up очень круто! даже я с знаниями не мог написать
 
всем хай очередной завоз
щит гпт присутствует тк я не мог понять почему не идет музыка(если у вас открыто два потока музыки или видео то приоретет будет на тот который был запущен раннее)
ОБЯЗАТЕЛЬНО НУЖНА ЛИБКА БЕЗ НЕЕ НИЧЕГО НЕ РАБОТАЕТ -
Пожалуйста, авторизуйтесь для просмотра ссылки.

Закидывать либку в вашу папку с либками
сс -
Пожалуйста, авторизуйтесь для просмотра ссылки.
(смотреть со звуком)
код -
Java:
Expand Collapse Copy
import dev.kodek.client.api.events.orbit.EventHandler;
import dev.kodek.client.managers.events.render.Render2DEvent;
import dev.kodek.client.screen.InterFace;
import dev.kodek.client.screen.hud.IRenderer;
import dev.kodek.client.utils.animation.Animation;
import dev.kodek.client.utils.animation.util.Easings;
import dev.kodek.client.utils.render.color.ColorUtil;
import dev.kodek.client.utils.render.draw.RenderUtil;
import dev.kodek.client.utils.render.draw.Round;
import dev.kodek.client.utils.render.font.Fonts;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.util.ResourceLocation;
import net.mojang.blaze3d.matrix.MatrixStack;
import org.lwjgl.opengl.GL11;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class MusicBarRenderer implements IRenderer {

    private String song = null;
    private String artist = null;
    private boolean playing = false;
    private byte[] cover = null;
    private boolean coverLoaded = false;

    private ResourceLocation coverTexture = null;
    private static final ResourceLocation DEFAULT_COVER = new ResourceLocation("texture/Cat.png");

    private final float[] barH = {0f, 0f, 0f, 0f};
    private final float[] barTarget = {4f, 7f, 5f, 3f};
    private long lastWave = 0;

    private final Animation fade = new Animation();
    private final Animation bossAnim = new Animation();

    private float scroll = 0f;
    private long lastScroll = System.currentTimeMillis();

    private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(r -> {
        Thread t = new Thread(r, "music-thread");
        t.setDaemon(true);
        return t;
    });

    private static final float H = 18f;
    private static final float COVER_SIZE = 14f;
    private static final float TIME_SIZE = 8f;
    private static final float TEXT_SIZE = 6.5f;
    private static final float PAD = 5f;
    private static final float GAP = 7f;
    private static final float MAX_TEXT = 95f;
    private static final float EQ_W = 14f;
    private static final float BOSS_OFFSET = 28f;

    public MusicBarRenderer() {
        executor.scheduleAtFixedRate(this::fetchMusic, 0, 100, TimeUnit.MILLISECONDS);
        fade.set(0.0);
        bossAnim.set(0.0);
    }

    private void fetchMusic() {
        try {
            Class<?> mt = Class.forName("by.bonenaut7.mediatransport4j.api.MediaTransport");
            mt.getMethod("init").invoke(null);
            java.util.List<?> sessions = (java.util.List<?>) mt.getMethod("getMediaSessions").invoke(null);

            if (sessions != null && !sessions.isEmpty()) {
                Object active = null;
                for (Object s : sessions) {
                    boolean play = (Boolean) s.getClass().getMethod("isPlaying").invoke(s);
                    if (play) {
                        active = s;
                        break;
                    }
                }

                if (active == null) {
                    active = sessions.get(0);
                }

                String title = (String) active.getClass().getMethod("getTitle").invoke(active);
                String artistName = (String) active.getClass().getMethod("getArtist").invoke(active);
                boolean isPlaying = (Boolean) active.getClass().getMethod("isPlaying").invoke(active);

                song = title != null ? title : "Unknown";
                artist = artistName != null ? artistName : "Artist";
                playing = isPlaying;

                try {
                    Object thumb = active.getClass().getMethod("getThumbnail").invoke(active);
                    if (thumb instanceof BufferedImage) {
                        BufferedImage img = (BufferedImage) thumb;
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        ImageIO.write(img, "png", baos);
                        byte[] newCover = baos.toByteArray();

                        if (cover == null || !java.util.Arrays.equals(cover, newCover)) {
                            cover = newCover;
                            coverLoaded = false;
                        }
                    }
                } catch (NoSuchMethodException ignored) {}
            } else {
                song = null;
                cover = null;
                coverLoaded = false;
            }
        } catch (ClassNotFoundException ignored) {
            executor.shutdown();
        } catch (Exception ignored) {
            song = null;
        }
        updateBars();
    }

    private void loadCover() {
        if (coverLoaded) return;

        if (cover != null && cover.length > 0) {
            try {
                InputStream in = new ByteArrayInputStream(cover);
                BufferedImage img = ImageIO.read(in);
                if (img != null) {
                    int w = img.getWidth();
                    int h = img.getHeight();
                    NativeImage nativeImg = new NativeImage(w, h, false);

                    for (int x = 0; x < w; x++) {
                        for (int y = 0; y < h; y++) {
                            nativeImg.setPixelRGBA(x, y, img.getRGB(x, y));
                        }
                    }

                    DynamicTexture dynTex = new DynamicTexture(nativeImg);
                    coverTexture = mc.getTextureManager().getDynamicTextureLocation("music_cover_" + System.currentTimeMillis(), dynTex);
                    coverLoaded = true;
                    return;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        coverTexture = DEFAULT_COVER;
        coverLoaded = true;
    }

    private void updateBars() {
        if (playing) {
            if (System.currentTimeMillis() - lastWave > 95) {
                lastWave = System.currentTimeMillis();
                barTarget[0] = 3f + (float)(Math.random() * 7f);
                barTarget[1] = 2f + (float)(Math.random() * 10f);
                barTarget[2] = 4f + (float)(Math.random() * 5f);
                barTarget[3] = 3f + (float)(Math.random() * 6f);
            }
        } else {
            for (int i = 0; i < 4; i++) barTarget[i] = 0f;
        }
        for (int i = 0; i < 4; i++)
            barH[i] += (barTarget[i] - barH[i]) * 0.22f;
    }

    private boolean hasBoss() {
        return mc.ingameGUI.getBossOverlay().getMapBossInfos() != null &&
                !mc.ingameGUI.getBossOverlay().getMapBossInfos().isEmpty();
    }

    @Override
    @EventHandler
    public void render(Render2DEvent event) {
        if (song == null) {
            fade.run(0.0, 0.2, Easings.EXPO_IN, false);
            fade.update();
            bossAnim.update();
            return;
        }

        loadCover();

        bossAnim.update();
        boolean bossHere = hasBoss();
        bossAnim.run(bossHere ? 1.0 : 0.0, 0.25, Easings.EXPO_OUT, false);
        float bossShift = (float) bossAnim.get() * BOSS_OFFSET;

        fade.update();
        fade.run(1.0, 0.3, Easings.EXPO_OUT, false);
        float alpha = (float) fade.get();
        if (alpha < 0.02f) return;

        InterFace ui = InterFace.getInstance();
        MatrixStack stack = event.getMatrix();
        int accent = ui.themeColor();

        int screenW = mc.getMainWindow().getScaledWidth();

        String time = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm"));
        float timeW = Fonts.SFP_BOLD.getWidth(time, TIME_SIZE);

        String text = song + " - " + artist;
        float textW = Math.min(Fonts.SFP_MEDIUM.getWidth(text, TEXT_SIZE), MAX_TEXT);

        float wifiW = Fonts.ICON_DESHUX.getWidth("n", TEXT_SIZE + 0.5f);
        float pillW = PAD + COVER_SIZE + GAP + textW + GAP + EQ_W + PAD;
        float totalW = timeW + GAP + pillW + GAP + wifiW;

        float startX = (screenW - totalW) / 2f;
        float startY = 0f + bossShift;
        float centerY = startY + H / 2f;

        stack.push();
        stack.translate(screenW / 2f, centerY, 0);
        stack.scale(alpha, alpha, 1f);
        stack.translate(-screenW / 2f, -centerY, 0);

        float curX = startX;

        Fonts.SFP_BOLD.draw(stack, time, curX, centerY - TIME_SIZE / 2f - 0.5f,
                ColorUtil.getColor(210, (int)(225 * alpha)), TIME_SIZE);
        curX += timeW + GAP;

        float pillX = curX;
        RenderUtil.Shadow.drawShadow(stack, pillX - 3, startY - 3, pillW + 6, H + 6,
                8, alpha * 0.35f, ColorUtil.getColor(0));
        RenderUtil.Rounded.smooth(stack, pillX, startY, pillW, H,
                ColorUtil.getColor(28, 22, 38, (int)(218 * alpha)), Round.of(H / 2f));
        RenderUtil.Rounded.roundedOutline(stack, pillX, startY, pillW, H, 0.75f,
                ColorUtil.replAlpha(accent, alpha * 0.2f), Round.of(H / 2f));

        float innerX = pillX + PAD;

        float coverY = centerY - COVER_SIZE / 2f;
        RenderUtil.Rounded.smooth(stack, innerX, coverY, COVER_SIZE, COVER_SIZE,
                ColorUtil.replAlpha(accent, alpha * 0.32f), Round.of(COVER_SIZE / 3f));

        if (coverTexture != null) {
            mc.getTextureManager().bindTexture(coverTexture);
            RenderUtil.Texture.customRound(stack, innerX, coverY, COVER_SIZE, COVER_SIZE, alpha, 0, 0, 0, 0, Round.of(COVER_SIZE / 3f));
        } else {
            Fonts.ICON_DESHUX.draw(stack, "v",
                    innerX + COVER_SIZE / 2f - 3.5f, coverY + COVER_SIZE / 2f - 3.5f,
                    ColorUtil.replAlpha(accent, alpha * 0.75f), TEXT_SIZE);
        }

        innerX += COVER_SIZE + GAP;

        drawScrollText(stack, text, innerX, centerY - TEXT_SIZE / 2f - 0.5f, textW, TEXT_SIZE,
                ColorUtil.getColor(215, (int)(218 * alpha)));
        innerX += textW + GAP;

        float barW = 2.5f, barGap = 1.5f;
        float barBottom = centerY + 4f;
        if (playing) {
            for (int i = 0; i < 4; i++) {
                float bh = Math.max(1f, Math.min(barH[i] * (H / 11f), H - 4f));
                RenderUtil.Rounded.smooth(stack,
                        innerX + i * (barW + barGap), barBottom - bh,
                        barW, bh,
                        ColorUtil.replAlpha(accent, alpha * 0.85f), Round.of(barW / 2f));
            }
        } else {
            float pauseH = 8f, pauseW = 2f, pauseGap = 2f;
            float pauseX = innerX + (EQ_W - pauseW * 2 - pauseGap) / 2f;
            float pauseY = centerY - pauseH / 2f;
            RenderUtil.Rounded.smooth(stack, pauseX, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
            RenderUtil.Rounded.smooth(stack, pauseX + pauseW + pauseGap, pauseY, pauseW, pauseH,
                    ColorUtil.getColor(190, (int)(155 * alpha)), Round.of(0.5f));
        }

        curX = pillX + pillW + GAP;
        Fonts.ICON_DESHUX.draw(stack, "n", curX, centerY - (TEXT_SIZE + 0.5f) / 2f - 0.5f,
                ColorUtil.getColor(195, (int)(200 * alpha)), TEXT_SIZE + 0.5f);

        stack.pop();
    }

    private void drawScrollText(MatrixStack stack, String text, float x, float y,
                                float maxW, float fontSize, int color) {
        float textW = Fonts.SFP_MEDIUM.getWidth(text, fontSize);
        if (textW <= maxW) {
            Fonts.SFP_MEDIUM.draw(stack, text, x, y, color, fontSize);
            scroll = 0f;
            return;
        }

        long now = System.currentTimeMillis();
        float delta = (now - lastScroll) / 1000f;
        lastScroll = now;
        float speed = 20f, gap = 28f;
        scroll += delta * speed;
        if (scroll > textW + gap) scroll = 0f;

        double scale = mc.getMainWindow().getScaleFactor();
        int sx = (int)(x * scale);
        int sy = (int)(mc.getFramebuffer().framebufferHeight - (y + fontSize + 4) * scale);
        int sw = (int)(maxW * scale);
        int sh = (int)((fontSize + 6) * scale);

        GL11.glEnable(GL11.GL_SCISSOR_TEST);
        GL11.glScissor(sx, sy, sw, sh);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll, y, color, fontSize);
        Fonts.SFP_MEDIUM.draw(stack, text, x - scroll + textW + gap, y, color, fontSize);
        GL11.glDisable(GL11.GL_SCISSOR_TEST);
    }
}

забыл упомянуть база excellent\night 1.1.3 кто сможет тот перенесет на другие
полное говнище
 
Назад
Сверху Снизу