Welcome on MasterOf13FPS! MasterOf13FPS

Register today or sign up if you are already a member and never miss any cool content again :)

Animierte GIF rendern

TypeInNameHere

New member
Joined
Oct 1, 2020
Messages
13
Reaction score
0
Points
0
Kann mir jemand sagen wie ich in Minecraft eine animierte GIF renderen kann?
 
Wenn du ganz viel Lust hast, kannst du ein gif mit java in buffered images umwandeln und dann per dynamic texture ne resource location draus bekommen. Oder du macht es wie die anderen geschrieben haben so, indem du einzelne Bilder nacheinander renderst.
Der Code unten würde dir das nächste Bild returnen
Das Bild rendern kannst du dann mit z.B. der Methode, die es in der Gui Klasse gibt.
Der Code ist am handy geschrieben.
Code:
public class GifAntimation {



    private int pics;

    private int cpic;

    private TimeHelper time = new TimeHelper();

    private ResourceLocation current;

    private String path;

    private String name;



    public GifAntimation(int pics, String path, String name) {

        this.pics = pics;

        this.path = path;

        this.name = name;

        this.cpic = 0;

    }



    public ResourceLocation getNextFrame() {

        if(time.hasReached(100)&&current!=null){

        ResourceLocation loc = new ResourceLocation(this.path + this.name + this.cpic + ".png");

        if (this.cpic >= this.pics)

            this.cpic = 0;

        this.cpic++;

        time.reset();

        return current = loc;

    }else{

        return getCurrent();

    }

}



    public ResourceLocation getCurrent() {

        return this.current;

    }



}
Du solltest denke ich vlt auch ne hashmap für die Nummer und die resource location machen
 
Wenn du ganz viel Lust hast, kannst du ein gif mit java in buffered images umwandeln und dann per dynamic texture ne resource location draus bekommen. Oder du macht es wie die anderen geschrieben haben so, indem du einzelne Bilder nacheinander renderst.
Der Code unten würde dir das nächste Bild returnen
Das Bild rendern kannst du dann mit z.B. der Methode, die es in der Gui Klasse gibt.
Der Code ist am handy geschrieben.
Code:
public class GifAntimation {



    private int pics;

    private int cpic;

    private TimeHelper time = new TimeHelper();

    private ResourceLocation current;

    private String path;

    private String name;



    public GifAntimation(int pics, String path, String name) {

        this.pics = pics;

        this.path = path;

        this.name = name;

        this.cpic = 0;

    }



    public ResourceLocation getNextFrame() {

        if(time.hasReached(100)&&current!=null){

        ResourceLocation loc = new ResourceLocation(this.path + this.name + this.cpic + ".png");

        if (this.cpic >= this.pics)

            this.cpic = 0;

        this.cpic++;

        time.reset();

        return current = loc;

    }else{

        return getCurrent();

    }

}



    public ResourceLocation getCurrent() {

        return this.current;

    }



}
Du solltest denke ich vlt auch ne hashmap für die Nummer und die resource location machen
Jo habe jetzt die Methode mit den Bildern einzeln rendern.
Ist zwar halt nervig wenn man immer eine GIF in mehrere Dateien umwandeln muss, aber immerhin habe ich ein animiertes Bild. :)
 
Auf der Seite ist kein Code :(
public void explodelogo() {

if (this.timerUtil.reached(90)) {

debug++;
timerUtil.reset();
}
if (debug >= 25) {
debug = 1;

} else {
ScaledResolution sr = new ScaledResolution(mc);
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("bg/gif/gif2/1 (" + debug + ").png"));
Gui.drawScaledCustomSizeModalRect(0, 0, 0.0f, 0.0f, sr.getScaledWidth(), sr.getScaledHeight(), 85, 80, (float) sr.getScaledWidth(), (float) sr.getScaledHeight());
}

}
 
shape1
shape2
shape3
shape4
shape5
shape6
Back
Top