Визуальная часть Гифка в худе | exp 3.1 ready

Ну типа гифка лол
SS
Посмотреть вложение 318970
Утилка для гифки:

GifAnimation:
Expand Collapse Copy
package im.expensive.utils.animations.impl;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.util.ResourceLocation;
import im.expensive.utils.math.StopWatch;

import java.util.ArrayList;
import java.util.List;

@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class GifAnimation {
    final List<ResourceLocation> frames = new ArrayList<>();
    final StopWatch timer = new StopWatch();
    @Getter
    int currentFrame = 0;
    final int frameDelay;
    final String basePath;
    final int totalFrames;
    boolean loaded = false;

    public GifAnimation(String basePath, int totalFrames, int frameDelay) {
        this.basePath = basePath;
        this.totalFrames = totalFrames;
        this.frameDelay = frameDelay;
        loadFrames();
    }

    private void loadFrames() {
        if (loaded) return;

        for (int i = 0; i < totalFrames; i++) {
            try {
                ResourceLocation frame = new ResourceLocation("expensive/images/gif/" + i + ".gif");
                frames.add(frame);
            } catch (Exception e) {
                System.err.println("Не удалось загрузить кадр GIF: " + i);
            }
        }
        loaded = true;

        System.out.println("Загружено кадров GIF: " + frames.size());
    }

    public void update() {
        if (frames.isEmpty()) return;

        if (timer.isReached(frameDelay)) {
            currentFrame = (currentFrame + 1) % frames.size();
            timer.reset();
        }
    }

    public ResourceLocation getCurrentFrame() {
        if (frames.isEmpty()) {
            return null;
        }
        return frames.get(currentFrame);
    }

    public void reset() {
        currentFrame = 0;
        timer.reset();
    }

    public boolean isLoaded() {
        return loaded && !frames.isEmpty();
    }

    public int getLoadedFramesCount() {
        return frames.size();
    }
}

Класс худа

Hud:
Expand Collapse Copy
package im.expensive.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import im.expensive.Expensive;
import im.expensive.events.EventDisplay;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.api.impl.BooleanSetting;
import im.expensive.functions.api.impl.ModeListSetting;
import im.expensive.ui.display.impl.*;
import im.expensive.ui.styles.StyleManager;
import im.expensive.utils.animations.impl.GifAnimation;
import im.expensive.utils.drag.Dragging;
import im.expensive.utils.render.ColorUtils;
import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;

@FieldDefaults(level = AccessLevel.PRIVATE)
@FunctionRegister(name = "HUD", type = Category.Render)
public class HUD extends Function {

    private final ModeListSetting elements = new ModeListSetting("Элементы",
            new BooleanSetting("Ватермарка", true),
            new BooleanSetting("Список модулей", true),
            new BooleanSetting("Координаты", true),
            new BooleanSetting("Эффекты", true),
            new BooleanSetting("Список модерации", true),
            new BooleanSetting("Активные бинды", true),
            new BooleanSetting("Активный таргет", true),
            new BooleanSetting("Броня", true),
            new BooleanSetting("BPS", true),
            new BooleanSetting("GIF анимация", true)
    );

    final WatermarkRenderer watermarkRenderer;
    final ArrayListRenderer arrayListRenderer;
    final CoordsRenderer coordsRenderer;
    final PotionRenderer potionRenderer;
    final KeyBindRenderer keyBindRenderer;
    final TargetInfoRenderer targetInfoRenderer;
    final ArmorRenderer armorRenderer;
    final StaffListRenderer staffListRenderer;
    final BpsRenderer bpsRenderer;

    final GifAnimation hudGif;
    final Dragging gifDrag;

    @Subscribe
    private void onUpdate(EventUpdate e) {
        if (mc.gameSettings.showDebugInfo) {
            return;
        }

        if (elements.getValueByName("GIF анимация").get()) {
            hudGif.update();
        }

        if (elements.getValueByName("Список модерации").get()) staffListRenderer.update(e);
        if (elements.getValueByName("Список модулей").get()) arrayListRenderer.update(e);
    }

    @Subscribe
    private void onDisplay(EventDisplay e) {
        if (mc.gameSettings.showDebugInfo || e.getType() != EventDisplay.Type.POST) {
            return;
        }

        if (elements.getValueByName("Координаты").get()) coordsRenderer.render(e);
        if (elements.getValueByName("Эффекты").get()) potionRenderer.render(e);
        if (elements.getValueByName("Ватермарка").get()) watermarkRenderer.render(e);
        if (elements.getValueByName("Список модулей").get()) arrayListRenderer.render(e);
        if (elements.getValueByName("Активные бинды").get()) keyBindRenderer.render(e);
        if (elements.getValueByName("Список модерации").get()) staffListRenderer.render(e);
        if (elements.getValueByName("Активный таргет").get()) targetInfoRenderer.render(e);
        if (elements.getValueByName("BPS").get()) bpsRenderer.render(e);
        if (elements.getValueByName("GIF анимация").get()) renderGif(e);
    }

    public HUD() {
        watermarkRenderer = new WatermarkRenderer();
        arrayListRenderer = new ArrayListRenderer();
        coordsRenderer = new CoordsRenderer();
        Dragging potions = Expensive.getInstance().createDrag(this, "Potions", 278, 5);
        armorRenderer = new ArmorRenderer();
        Dragging keyBinds = Expensive.getInstance().createDrag(this, "KeyBinds", 185, 5);
        Dragging dragging = Expensive.getInstance().createDrag(this, "TargetHUD", 74, 128);
        Dragging staffList = Expensive.getInstance().createDrag(this, "StaffList", 96, 5);
        Dragging bpsDrag = Expensive.getInstance().createDrag(this, "BPS", 50, 80);

        hudGif = new GifAnimation("expensive/images/gif/", 12, 100);
        gifDrag = Expensive.getInstance().createDrag(this, "GifAnimation", 200, 50);

        potionRenderer = new PotionRenderer(potions);
        keyBindRenderer = new KeyBindRenderer(keyBinds);
        staffListRenderer = new StaffListRenderer(staffList);
        targetInfoRenderer = new TargetInfoRenderer(dragging);
        bpsRenderer = new BpsRenderer(bpsDrag);

        addSettings(elements);
    }

    private void renderGif(EventDisplay e) {
        float x = gifDrag.getX();
        float y = gifDrag.getY();
        float width = 50;
        float height = 50;

        gifDrag.setWidth(width);
        gifDrag.setHeight(height);

        ResourceLocation currentFrame = hudGif.getCurrentFrame();

        if (currentFrame != null) {
            GL11.glPushMatrix();
            GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);

            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

            GL11.glEnable(GL11.GL_LINE_SMOOTH);
            GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);

            mc.getTextureManager().bindTexture(currentFrame);

            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);

            AbstractGui.blit(e.getMatrixStack(), (int)x, (int)y, 0, 0,
                    (int)width, (int)height, (int)width, (int)height);

            GL11.glPopAttrib();
            GL11.glPopMatrix();
        }
    }

    public static int getColor(int index) {
        StyleManager styleManager = Expensive.getInstance().getStyleManager();
        return ColorUtils.gradient(styleManager.getCurrentStyle().getFirstColor().getRGB(),
                styleManager.getCurrentStyle().getSecondColor().getRGB(), index * 16, 10);
    }

    public static int getColor(int index, float mult) {
        StyleManager styleManager = Expensive.getInstance().getStyleManager();
        return ColorUtils.gradient(styleManager.getCurrentStyle().getFirstColor().getRGB(),
                styleManager.getCurrentStyle().getSecondColor().getRGB(), (int) (index * mult), 10);
    }

    public static int getColor(int firstColor, int secondColor, int index, float mult) {
        return ColorUtils.gradient(firstColor, secondColor, (int) (index * mult), 10);
    }
}

Гайдики:
Как сделать свою гифку?
1. Находим гифку в инете и делим её на кадры с помощью
Пожалуйста, авторизуйтесь для просмотра ссылки.
(noad)
2. Создаем папку gif в ассетах экспы
3. Закидиваем туда кадры
Готово!
прикольно
 
Ну типа гифка лол
SS
Посмотреть вложение 318970
Утилка для гифки:

GifAnimation:
Expand Collapse Copy
package im.expensive.utils.animations.impl;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.util.ResourceLocation;
import im.expensive.utils.math.StopWatch;

import java.util.ArrayList;
import java.util.List;

@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class GifAnimation {
    final List<ResourceLocation> frames = new ArrayList<>();
    final StopWatch timer = new StopWatch();
    @Getter
    int currentFrame = 0;
    final int frameDelay;
    final String basePath;
    final int totalFrames;
    boolean loaded = false;

    public GifAnimation(String basePath, int totalFrames, int frameDelay) {
        this.basePath = basePath;
        this.totalFrames = totalFrames;
        this.frameDelay = frameDelay;
        loadFrames();
    }

    private void loadFrames() {
        if (loaded) return;

        for (int i = 0; i < totalFrames; i++) {
            try {
                ResourceLocation frame = new ResourceLocation("expensive/images/gif/" + i + ".gif");
                frames.add(frame);
            } catch (Exception e) {
                System.err.println("Не удалось загрузить кадр GIF: " + i);
            }
        }
        loaded = true;

        System.out.println("Загружено кадров GIF: " + frames.size());
    }

    public void update() {
        if (frames.isEmpty()) return;

        if (timer.isReached(frameDelay)) {
            currentFrame = (currentFrame + 1) % frames.size();
            timer.reset();
        }
    }

    public ResourceLocation getCurrentFrame() {
        if (frames.isEmpty()) {
            return null;
        }
        return frames.get(currentFrame);
    }

    public void reset() {
        currentFrame = 0;
        timer.reset();
    }

    public boolean isLoaded() {
        return loaded && !frames.isEmpty();
    }

    public int getLoadedFramesCount() {
        return frames.size();
    }
}

Класс худа

Hud:
Expand Collapse Copy
package im.expensive.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import im.expensive.Expensive;
import im.expensive.events.EventDisplay;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.api.impl.BooleanSetting;
import im.expensive.functions.api.impl.ModeListSetting;
import im.expensive.ui.display.impl.*;
import im.expensive.ui.styles.StyleManager;
import im.expensive.utils.animations.impl.GifAnimation;
import im.expensive.utils.drag.Dragging;
import im.expensive.utils.render.ColorUtils;
import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;

@FieldDefaults(level = AccessLevel.PRIVATE)
@FunctionRegister(name = "HUD", type = Category.Render)
public class HUD extends Function {

    private final ModeListSetting elements = new ModeListSetting("Элементы",
            new BooleanSetting("Ватермарка", true),
            new BooleanSetting("Список модулей", true),
            new BooleanSetting("Координаты", true),
            new BooleanSetting("Эффекты", true),
            new BooleanSetting("Список модерации", true),
            new BooleanSetting("Активные бинды", true),
            new BooleanSetting("Активный таргет", true),
            new BooleanSetting("Броня", true),
            new BooleanSetting("BPS", true),
            new BooleanSetting("GIF анимация", true)
    );

    final WatermarkRenderer watermarkRenderer;
    final ArrayListRenderer arrayListRenderer;
    final CoordsRenderer coordsRenderer;
    final PotionRenderer potionRenderer;
    final KeyBindRenderer keyBindRenderer;
    final TargetInfoRenderer targetInfoRenderer;
    final ArmorRenderer armorRenderer;
    final StaffListRenderer staffListRenderer;
    final BpsRenderer bpsRenderer;

    final GifAnimation hudGif;
    final Dragging gifDrag;

    @Subscribe
    private void onUpdate(EventUpdate e) {
        if (mc.gameSettings.showDebugInfo) {
            return;
        }

        if (elements.getValueByName("GIF анимация").get()) {
            hudGif.update();
        }

        if (elements.getValueByName("Список модерации").get()) staffListRenderer.update(e);
        if (elements.getValueByName("Список модулей").get()) arrayListRenderer.update(e);
    }

    @Subscribe
    private void onDisplay(EventDisplay e) {
        if (mc.gameSettings.showDebugInfo || e.getType() != EventDisplay.Type.POST) {
            return;
        }

        if (elements.getValueByName("Координаты").get()) coordsRenderer.render(e);
        if (elements.getValueByName("Эффекты").get()) potionRenderer.render(e);
        if (elements.getValueByName("Ватермарка").get()) watermarkRenderer.render(e);
        if (elements.getValueByName("Список модулей").get()) arrayListRenderer.render(e);
        if (elements.getValueByName("Активные бинды").get()) keyBindRenderer.render(e);
        if (elements.getValueByName("Список модерации").get()) staffListRenderer.render(e);
        if (elements.getValueByName("Активный таргет").get()) targetInfoRenderer.render(e);
        if (elements.getValueByName("BPS").get()) bpsRenderer.render(e);
        if (elements.getValueByName("GIF анимация").get()) renderGif(e);
    }

    public HUD() {
        watermarkRenderer = new WatermarkRenderer();
        arrayListRenderer = new ArrayListRenderer();
        coordsRenderer = new CoordsRenderer();
        Dragging potions = Expensive.getInstance().createDrag(this, "Potions", 278, 5);
        armorRenderer = new ArmorRenderer();
        Dragging keyBinds = Expensive.getInstance().createDrag(this, "KeyBinds", 185, 5);
        Dragging dragging = Expensive.getInstance().createDrag(this, "TargetHUD", 74, 128);
        Dragging staffList = Expensive.getInstance().createDrag(this, "StaffList", 96, 5);
        Dragging bpsDrag = Expensive.getInstance().createDrag(this, "BPS", 50, 80);

        hudGif = new GifAnimation("expensive/images/gif/", 12, 100);
        gifDrag = Expensive.getInstance().createDrag(this, "GifAnimation", 200, 50);

        potionRenderer = new PotionRenderer(potions);
        keyBindRenderer = new KeyBindRenderer(keyBinds);
        staffListRenderer = new StaffListRenderer(staffList);
        targetInfoRenderer = new TargetInfoRenderer(dragging);
        bpsRenderer = new BpsRenderer(bpsDrag);

        addSettings(elements);
    }

    private void renderGif(EventDisplay e) {
        float x = gifDrag.getX();
        float y = gifDrag.getY();
        float width = 50;
        float height = 50;

        gifDrag.setWidth(width);
        gifDrag.setHeight(height);

        ResourceLocation currentFrame = hudGif.getCurrentFrame();

        if (currentFrame != null) {
            GL11.glPushMatrix();
            GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);

            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

            GL11.glEnable(GL11.GL_LINE_SMOOTH);
            GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);

            mc.getTextureManager().bindTexture(currentFrame);

            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);

            AbstractGui.blit(e.getMatrixStack(), (int)x, (int)y, 0, 0,
                    (int)width, (int)height, (int)width, (int)height);

            GL11.glPopAttrib();
            GL11.glPopMatrix();
        }
    }

    public static int getColor(int index) {
        StyleManager styleManager = Expensive.getInstance().getStyleManager();
        return ColorUtils.gradient(styleManager.getCurrentStyle().getFirstColor().getRGB(),
                styleManager.getCurrentStyle().getSecondColor().getRGB(), index * 16, 10);
    }

    public static int getColor(int index, float mult) {
        StyleManager styleManager = Expensive.getInstance().getStyleManager();
        return ColorUtils.gradient(styleManager.getCurrentStyle().getFirstColor().getRGB(),
                styleManager.getCurrentStyle().getSecondColor().getRGB(), (int) (index * mult), 10);
    }

    public static int getColor(int firstColor, int secondColor, int index, float mult) {
        return ColorUtils.gradient(firstColor, secondColor, (int) (index * mult), 10);
    }
}

Гайдики:
Как сделать свою гифку?
1. Находим гифку в инете и делим её на кадры с помощью
Пожалуйста, авторизуйтесь для просмотра ссылки.
(noad)
2. Создаем папку gif в ассетах экспы
3. Закидиваем туда кадры
Готово!
а в чем прикол этого? это просто загрузка картинок через утилиту маинкрафта(ResourceLocation)
 
Назад
Сверху Снизу