Начинающий
- Статус
- Оффлайн
- Регистрация
- 22 Авг 2022
- Сообщения
- 423
- Реакции
- 4
- Выберите загрузчик игры
- Vanilla
Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:
- бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
- маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
- приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
- обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.
Спасибо!
Приветствую югейм
Сливаю Музыкальный плеер под Excellent Recode с анимациями и кликами останавливает музыку и переключает её (кто хочет улучшит)
Причина слива: Делаю динамический остров и перенес его туда
Иконки сами думаю сделаете, заливать сюда нет смысла
Библиотека:
SS:
Код:
Сливаю Музыкальный плеер под Excellent Recode с анимациями и кликами останавливает музыку и переключает её (кто хочет улучшит)
Причина слива: Делаю динамический остров и перенес его туда
Иконки сами думаю сделаете, заливать сюда нет смысла
Библиотека:
Пожалуйста, авторизуйтесь для просмотра ссылки.
SS:
Код:
MusicHudRenderer:
package dev.centric.client.screen.hud.impl;
import dev.centric.client.managers.events.input.MousePressEvent;
import dev.centric.client.managers.events.render.Render2DEvent;
import dev.centric.client.managers.module.impl.render.Hud;
import dev.centric.client.managers.module.settings.impl.DragSetting;
import dev.centric.client.screen.hud.IMousePress;
import dev.centric.client.screen.hud.IRenderer;
import dev.centric.client.utils.animation.Animation;
import dev.centric.client.utils.render.color.ColorUtil;
import dev.centric.client.utils.render.draw.RectUtil;
import dev.centric.client.utils.render.draw.RenderUtil;
import dev.centric.client.utils.render.draw.Round;
import dev.centric.client.utils.render.draw.ScissorUtil;
import dev.centric.client.utils.render.font.Fonts;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.util.ResourceLocation;
import net.mojang.blaze3d.matrix.MatrixStack;
import dev.redstones.mediaplayerinfo.IMediaSession;
import dev.redstones.mediaplayerinfo.MediaPlayerInfo;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.mojang.blaze3d.platform.GlStateManager;
import org.lwjgl.opengl.GL11;
import java.io.ByteArrayInputStream;
import java.util.Arrays;
import java.util.List;
/**
* @author johon0
* @Date: 03.08.2025 | 23:04
*/
@SuppressWarnings("all")
public class MusicHudRenderer implements IRenderer, IMousePress {
private final DragSetting drag;
private final MediaPlayerInfo mediaPlayerInfo = MediaPlayerInfo.Instance;
private String currentTrackTitle = "";
private String artist = "";
private long posit;
private long durat;
private boolean pause;
private boolean sessionActive;
private long lastUpdate = System.currentTimeMillis();
private static final long UPDATE_INTERVAL = 1000;
private String currentPlayer = "Неизвестное приложение";
private Animation pauseAnim = new Animation();
private Animation transitionAnim = new Animation();
private Animation soonAnim = new Animation();
private byte[] artworkBytes;
private byte[] lastArtworkBytes;
private ResourceLocation artworkTexture;
public MusicHudRenderer(DragSetting drag) {
this.drag = drag;
}
@Override
public void render(Render2DEvent event) {
MatrixStack matrix = event.getMatrix();
float width = 95;
float height = 45;
float x = drag.position.x;
float y = drag.position.y;
pauseAnim.update();
transitionAnim.update();
soonAnim.update();
if (System.currentTimeMillis() - lastUpdate >= UPDATE_INTERVAL) {
lastUpdate = System.currentTimeMillis();
updateTrackTitle();
}
int bgColor2 = ColorUtil.multAlpha(ColorUtil.getColor(29, 29, 31, 255), 1);
int bgColor1 = ColorUtil.multAlpha(ColorUtil.getColor(14, 14, 16, 255), 1);
int outlineColor = ColorUtil.multAlpha(ColorUtil.getColor(29, 29, 31, 255), 1);
transitionAnim.run(!sessionActive ? 1.0f : 0.0, 1,true);
soonAnim.run(!sessionActive ? 0.0f : 1.0, 1,true);
RectUtil.drawRoundedRectShadowed(
matrix,
x, y, width, height,
Hud.getInstance().rectRound().getValue(),
2,
bgColor1, bgColor2, bgColor1, bgColor1,
false, true, true, false
);
RenderUtil.Rounded.roundedOutline(
matrix,
x, y, width, height,
1,
outlineColor, outlineColor, outlineColor, outlineColor,
Round.of(Hud.getInstance().rectRound().getValue())
);
String displayText = currentTrackTitle;
String artistText = sessionActive ? "" : artist;
if (!sessionActive && !"Ожидаю...".equals(currentTrackTitle)) {
renderArtwork(x, y, event);
}
Fonts.SUISSE_INTL_MEDIUM.draw(matrix, "Ожидаю", x + width/2f - Fonts.SUISSE_INTL_MEDIUM.getWidth("Ожидаю", 6.5f) / 2f, y + height / 2f - 6.5f/2f, ColorUtil.multAlpha(ColorUtil.WHITE,soonAnim.get()), 6.5f);
stripFont.draw(font, matrix, displayText, x + 35, y + 5, width - 50, ColorUtil.multAlpha(ColorUtil.WHITE,transitionAnim.get()), 6.5f, 5);
Fonts.MUSIC.draw(matrix,currentPlayer,x + width - Fonts.MUSIC.getWidth(currentPlayer,10.5f) - 5,y + 2,ColorUtil.multAlpha(ColorUtil.WHITE,transitionAnim.get()),14.5f);
if (!artistText.isEmpty()) {
stripFont.draw(font, matrix, artistText, x + 35, y + 14, width - 40,
ColorUtil.multAlpha(ColorUtil.getColor(177, 177, 177), transitionAnim.get()), 5f, 5);
}
if (!sessionActive) {
RenderUtil.Rounded.smooth(matrix, x + 35, y + height - 15, width - 40, 3,
ColorUtil.multAlpha(ColorUtil.getColor(45, 45, 45, 255),transitionAnim.get()), Round.of(2));
int progressColor = ColorUtil.multAlpha(theme().clientColor(),transitionAnim.get());
RenderUtil.Rounded.smooth(matrix, x + 35, y + height - 15, (width - 40) * getProgress(), 3,
progressColor, progressColor, progressColor, progressColor, Round.of(2));
Fonts.MUSICPLAYER.drawCenter(matrix, pause ? "a" : "b", x + width / 2, y + height - 8, ColorUtil.multAlpha(ColorUtil.WHITE,transitionAnim.get()), 7);
Fonts.MUSICPLAYER.drawCenter(matrix, "c", x + width / 2 + Fonts.MUSICPLAYER.getWidth(pause ? "a" : "b", 7) + 2.5f, y + height - 8, ColorUtil.multAlpha(ColorUtil.WHITE,transitionAnim.get()), 7);
Fonts.MUSICPLAYER.drawCenter(matrix, "d", x + width / 2 - Fonts.MUSICPLAYER.getWidth(pause ? "a" : "b", 7) - 2.5f, y + height - 8, ColorUtil.multAlpha(ColorUtil.WHITE,transitionAnim.get()), 7);
String timeText = formatDuration(durat);
String timeposText = formatDuration(posit);
font.draw(matrix, timeposText, x + 35, y + 23,
ColorUtil.multAlpha(ColorUtil.getColor(177, 177, 177),transitionAnim.get()), 5f);
font.draw(matrix, timeText, x + width - 5 - font.getWidth(timeText, 5f), y + 23,
ColorUtil.multAlpha(ColorUtil.getColor(177, 177, 177),transitionAnim.get()), 5f);
pauseAnim.run(pause ? 1.0f : 0.0f,0.5f,true);
if (pause) {
RectUtil.drawRoundedRectShadowed(
matrix,
x, y, width, height,
Hud.getInstance().rectRound().getValue(),
2,
ColorUtil.multAlpha(ColorUtil.multAlpha(ColorUtil.BLACK, 0.5f), pauseAnim.get()),
ColorUtil.multAlpha(ColorUtil.multAlpha(ColorUtil.BLACK, 0.5f), pauseAnim.get()),
ColorUtil.multAlpha(ColorUtil.multAlpha(ColorUtil.BLACK, 0.5f), pauseAnim.get()),
ColorUtil.multAlpha(ColorUtil.multAlpha(ColorUtil.BLACK, 0.5f), pauseAnim.get()),
false, true, true, false
);
RectUtil.drawRoundedRectShadowed(
matrix,
x + width / 2f - 10, y + height / 2f - 10, 20, 20,
20,
2,
ColorUtil.multAlpha(ColorUtil.BLACK, pauseAnim.get()),
ColorUtil.multAlpha(ColorUtil.BLACK, pauseAnim.get()),
ColorUtil.multAlpha(ColorUtil.BLACK, pauseAnim.get()),
ColorUtil.multAlpha(ColorUtil.BLACK, pauseAnim.get()),
false, true, true, true
);
Fonts.MUSICPLAYER.drawCenter(matrix, "a", x + width / 2, y + height / 2 - 4, ColorUtil.getColor(255, pauseAnim.get()), 10);
}
}
drag.size.set(width, height);
}
private void renderArtwork(float x, float y, Render2DEvent eventDisplay) {
float artworkSize = 27;
float artworkX = x + 5;
float artworkY = y + 5;
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
ScissorUtil.enable();
ScissorUtil.scissor(mc.getMainWindow(), artworkX, artworkY, artworkSize, artworkSize);
if (artworkBytes != null && artworkBytes.length > 0) {
if (lastArtworkBytes == null || !Arrays.equals(artworkBytes, lastArtworkBytes)) {
try {
if (artworkTexture != null) {
mc.getTextureManager().deleteTexture(artworkTexture);
}
NativeImage nativeImage = NativeImage.read(new ByteArrayInputStream(artworkBytes));
DynamicTexture dynamicTexture = new DynamicTexture(nativeImage);
dynamicTexture.setBlurMipmap(false, false);
artworkTexture = mc.getTextureManager().getDynamicTextureLocation("artwork", dynamicTexture);
GlStateManager.bindTexture(dynamicTexture.getGlTextureId());
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
lastArtworkBytes = artworkBytes.clone();
} catch (Exception e) {
artworkTexture = null;
e.printStackTrace();
}
}
if (artworkTexture != null) {
RenderUtil.bindTexture(artworkTexture);
RenderUtil.Texture.smooth(
eventDisplay.getMatrix(),
artworkX,
artworkY,
artworkSize,
artworkSize,
transitionAnim.get(), Round.of(4)
);
}
} else {
if (artworkTexture != null) {
mc.getTextureManager().deleteTexture(artworkTexture);
artworkTexture = null;
lastArtworkBytes = null;
}
}
GlStateManager.disableBlend();
ScissorUtil.disable();
}
private void updateTrackTitle() {
new Thread(() -> {
try {
List<IMediaSession> sessions = mediaPlayerInfo.getMediaSessions();
sessionActive = sessions == null || sessions.isEmpty();
if (!sessionActive) {
IMediaSession currentSession = sessions.get(0);
currentTrackTitle = currentSession.getMedia() == null ? "Нет данных" :
currentSession.getMedia().getTitle() == null ? "Нет данных" :
currentSession.getMedia().getTitle();
artist = currentSession.getMedia() == null ? "" :
currentSession.getMedia().getArtist() == null ? "" :
currentSession.getMedia().getArtist();
posit = currentSession.getMedia() == null ? 0 :
currentSession.getMedia().getPosition();
durat = currentSession.getMedia() == null ? 0 :
currentSession.getMedia().getDuration();
if (currentSession.getMedia() != null && currentSession.getMedia().getArtwork() != null) {
artworkBytes = currentSession.getMedia().getArtworkPng();
} else {
artworkBytes = null;
}
String owner = currentSession.getOwner();
if (owner.toLowerCase().contains("spotify")) {
currentPlayer = "a";
} else if (owner.toLowerCase().contains("yandex")) {
currentPlayer = "B";
} else if (owner.toLowerCase().contains("ayugram") || owner.toLowerCase().contains("telegram")) {
currentPlayer = "E";
} else if (owner.toLowerCase().contains("vk")) {
currentPlayer = "D";
} else if (owner.toLowerCase().contains("vkontakte")) {
currentPlayer = "D";
} else if (owner.toLowerCase().contains("edge")) {
currentPlayer = "C";
} else if (owner.toLowerCase().contains("microsoft edge")) {
currentPlayer = "C";
} else {
currentPlayer = "null";
}
} else {
currentTrackTitle = "";
artist = "";
posit = 0;
durat = 0;
artworkBytes = null;
}
} catch (Exception e) {
currentTrackTitle = "Ошибка";
artist = "";
artworkBytes = null;
}
}).start();
}
private String formatDuration(long duration) {
long hours = duration / 3600;
long remaining = duration % 3600;
long minutes = remaining / 60;
long seconds = remaining % 60;
if (hours > 0) {
return String.format("%d:%02d:%02d", hours, minutes, seconds);
} else {
return String.format("%02d:%02d", minutes, seconds);
}
}
private float getProgress() {
return (!sessionActive && durat > 0) ? (float) posit / (float) durat : 0.0F;
}
private boolean isHovered(float mouseX, float mouseY, float x, float y, float width, float height) {
return mouseX >= x && mouseX <= x + width &&
mouseY >= y && mouseY <= y + height;
}
@Override
public void mouse(MousePressEvent event) {
float width = 95;
float height = 45;
float x = drag.position.x;
float y = drag.position.y;
new Thread(() -> {
try {
List<IMediaSession> sessions = mediaPlayerInfo.getMediaSessions();
sessionActive = sessions == null || sessions.isEmpty();
if (!sessionActive) {
IMediaSession currentSession = sessions.get(0);
if (isHovered((float) event.getMouseX(), (float) event.getMouseY(),x + width/2 - Fonts.MUSICPLAYER.getWidth(pause ? "a": "b", 7) / 2, y + height - 8,Fonts.MUSICPLAYER.getWidth("a", 7),7)) {
currentSession.playPause();
pause = !pause;
}
if (isHovered((float) event.getMouseX(), (float) event.getMouseY(),x + width / 2 + Fonts.MUSICPLAYER.getWidth(pause ? "a" : "b", 7) + 2.5f, y + height - 8,Fonts.MUSICPLAYER.getWidth("a", 7),7)) {
currentSession.next();
}
if (isHovered((float) event.getMouseX(), (float) event.getMouseY(),x + width / 2 - Fonts.MUSICPLAYER.getWidth(pause ? "a" : "b", 7) - 4.5f, y + height - 8,Fonts.MUSICPLAYER.getWidth("a", 7),7)) {
currentSession.previous();
}
if (pause) {
if (isHovered((float) event.getMouseX(), (float) event.getMouseY(),x + width/2f - 10, y + height/2f - 10, 20, 20)) {
currentSession.play();
pause = false;
}
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}).start();
}
public String getCurrentPlayer() {
return currentPlayer;
}
public void setCurrentPlayer(String currentPlayer) {
this.currentPlayer = currentPlayer;
}
}