Вопрос Gif manager

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
17 Май 2023
Сообщения
222
Реакции
2
где найти gif manager? для воспроизведение гифок? ну или как сделать что бы можно было отрендерить гифку?
 
ну можно просто сконвертировать с гиф в пнг и по кадрово их проиграть
 
где найти gif manager? для воспроизведение гифок? ну или как сделать что бы можно было отрендерить гифку?
Ни где так как это не возможно. Но ты можешь покрадово рендерить картинку
 
и как это примерно реализовать? через time?
вот пример

gif:
Expand Collapse Copy
int gif = (Minecraft.getInstance().player.ticksExisted % 4) + 1; // 4 = количество картинок, картинки должны быть прономерованны
VisualHelper.drawImage(new ResourceLocation("client/gifs/" + gif + ".png"), 0,0,32,32,-1);
 
где найти gif manager? для воспроизведение гифок? ну или как сделать что бы можно было отрендерить гифку?
Megacode:
Expand Collapse Copy
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.util.ResourceLocation;

import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public class GifEngine {
    private int current = 0;
    private Counter counter = new Counter();
    private DynamicTexture texture;
    private List<DynamicTexture> frames;
    private int x;
    private int y;
    private int width;
    private int height;
    private int tiktok;
    private int ticks;

    public GifEngine(ResourceLocation rs, int width, int height, int tt) {
        this.texture = new DynamicTexture(width, height);
        this.width = width;
        this.height = height;
        this.frames = this.images(rs);
        this.ticks = tt;
    }

    public void update() {
        if (tiktok > ticks) {
            //1 seconds = 20 ticks
            if (this.counter.hasReached(Minecraft.getMinecraft().getTickLength()) && this.frames.size() > 0) {
                if (this.current > this.frames.size() - 1) {
                    this.current = 0;
                }
                this.texture = this.frames.get(this.current);
                ++this.current;
                this.counter.reset();
            }
            tiktok = 0;
        }
        tiktok++;
    }

    public void bind(int x, int y) {
        this.x = x;
        this.y = y;
        UIRender.bind((float)this.x + 5.0f, this.y, this.width / java777.scale.getScale(), this.height / java777.scale.getScale(), 1.0f, this.getTexture().getGlTextureId());
    }

    public List<DynamicTexture> images(ResourceLocation rs) {
        ArrayList<DynamicTexture> images = new ArrayList<DynamicTexture>();
        try {
            ImageReader reader = ImageIO.getImageReadersByFormatName("gif").next();
            InputStream xui = Minecraft.getMinecraft().getResourceManager().getResource(rs).getInputStream();
            ImageInputStream stream = ImageIO.createImageInputStream(xui);
            reader.setInput(stream);
            int count = reader.getNumImages(true);
            for (int index = 0; index < count; ++index) {
                BufferedImage frame = reader.read(index);
                images.add(new DynamicTexture(frame));
            }
        }
        catch (IOException iOException) {
            // empty catch block
        }
        return images;
    }

    public DynamicTexture getTexture() {
        return this.texture;
    }

    public void setTexture(DynamicTexture texture) {
        this.texture = texture;
    }

    public List<DynamicTexture> getFrames() {
        return this.frames;
    }

    public void setFrames(List<DynamicTexture> frames) {
        this.frames = frames;
    }
}
Megacode:
Expand Collapse Copy
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.util.ResourceLocation;

import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public class GifEngine {
    private int current = 0;
    private Counter counter = new Counter();
    private DynamicTexture texture;
    private List<DynamicTexture> frames;
    private int x;
    private int y;
    private int width;
    private int height;
    private int tiktok;
    private int ticks;

    public GifEngine(ResourceLocation rs, int width, int height, int tt) {
        this.texture = new DynamicTexture(width, height);
        this.width = width;
        this.height = height;
        this.frames = this.images(rs);
        this.ticks = tt;
    }

    public void update() {
        if (tiktok > ticks) {
            //1 seconds = 20 ticks
            if (this.counter.hasReached(Minecraft.getMinecraft().getTickLength()) && this.frames.size() > 0) {
                if (this.current > this.frames.size() - 1) {
                    this.current = 0;
                }
                this.texture = this.frames.get(this.current);
                ++this.current;
                this.counter.reset();
            }
            tiktok = 0;
        }
        tiktok++;
    }

    public void bind(int x, int y) {
        this.x = x;
        this.y = y;
        UIRender.bind((float)this.x + 5.0f, this.y, this.width / java777.scale.getScale(), this.height / java777.scale.getScale(), 1.0f, this.getTexture().getGlTextureId());
    }

    public List<DynamicTexture> images(ResourceLocation rs) {
        ArrayList<DynamicTexture> images = new ArrayList<DynamicTexture>();
        try {
            ImageReader reader = ImageIO.getImageReadersByFormatName("gif").next();
            InputStream xui = Minecraft.getMinecraft().getResourceManager().getResource(rs).getInputStream();
            ImageInputStream stream = ImageIO.createImageInputStream(xui);
            reader.setInput(stream);
            int count = reader.getNumImages(true);
            for (int index = 0; index < count; ++index) {
                BufferedImage frame = reader.read(index);
                images.add(new DynamicTexture(frame));
            }
        }
        catch (IOException iOException) {
            // empty catch block
        }
        return images;
    }

    public DynamicTexture getTexture() {
        return this.texture;
    }

    public void setTexture(DynamicTexture texture) {
        this.texture = texture;
    }

    public List<DynamicTexture> getFrames() {
        return this.frames;
    }

    public void setFrames(List<DynamicTexture> frames) {
        this.frames = frames;
    }
}
Хз работает ли на 1.16
 
Megacode:
Expand Collapse Copy
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.util.ResourceLocation;

import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public class GifEngine {
    private int current = 0;
    private Counter counter = new Counter();
    private DynamicTexture texture;
    private List<DynamicTexture> frames;
    private int x;
    private int y;
    private int width;
    private int height;
    private int tiktok;
    private int ticks;

    public GifEngine(ResourceLocation rs, int width, int height, int tt) {
        this.texture = new DynamicTexture(width, height);
        this.width = width;
        this.height = height;
        this.frames = this.images(rs);
        this.ticks = tt;
    }

    public void update() {
        if (tiktok > ticks) {
            //1 seconds = 20 ticks
            if (this.counter.hasReached(Minecraft.getMinecraft().getTickLength()) && this.frames.size() > 0) {
                if (this.current > this.frames.size() - 1) {
                    this.current = 0;
                }
                this.texture = this.frames.get(this.current);
                ++this.current;
                this.counter.reset();
            }
            tiktok = 0;
        }
        tiktok++;
    }

    public void bind(int x, int y) {
        this.x = x;
        this.y = y;
        UIRender.bind((float)this.x + 5.0f, this.y, this.width / java777.scale.getScale(), this.height / java777.scale.getScale(), 1.0f, this.getTexture().getGlTextureId());
    }

    public List<DynamicTexture> images(ResourceLocation rs) {
        ArrayList<DynamicTexture> images = new ArrayList<DynamicTexture>();
        try {
            ImageReader reader = ImageIO.getImageReadersByFormatName("gif").next();
            InputStream xui = Minecraft.getMinecraft().getResourceManager().getResource(rs).getInputStream();
            ImageInputStream stream = ImageIO.createImageInputStream(xui);
            reader.setInput(stream);
            int count = reader.getNumImages(true);
            for (int index = 0; index < count; ++index) {
                BufferedImage frame = reader.read(index);
                images.add(new DynamicTexture(frame));
            }
        }
        catch (IOException iOException) {
            // empty catch block
        }
        return images;
    }

    public DynamicTexture getTexture() {
        return this.texture;
    }

    public void setTexture(DynamicTexture texture) {
        this.texture = texture;
    }

    public List<DynamicTexture> getFrames() {
        return this.frames;
    }

    public void setFrames(List<DynamicTexture> frames) {
        this.frames = frames;
    }
}

Хз работает ли на 1.16
это все миф и ложь.
 
Назад
Сверху Снизу