GIF module

GIF: Minecraft 26.3 cheat module, full source for every implementation (1 client: Nicotine).

1 implementationHUD

Clients with this module

Full module source: 1 implementation

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

NicotineHUDsrc/client/java/nicotine/mod/mods/hud/GIF.javaJava · 106 lines · 3.2 KB
SettingsFPSRefreshImages
GIF.javaJava · Minecraft 26.3 · 106 lines · 3.2 KB · complete file, verbatimOriginal ↗
1
package nicotine.mod.mods.hud;
2
3
import net.minecraft.client.renderer.RenderPipelines;
4
import nicotine.events.GuiRenderBeforeEvent;
5
import nicotine.mod.HUDMod;
6
import nicotine.mod.ModCategory;
7
import nicotine.mod.option.ClickOption;
8
import nicotine.mod.option.DropDownOption;
9
import nicotine.mod.option.SliderOption;
10
import nicotine.util.EventBus;
11
import nicotine.util.render.GIFEntry;
12
import nicotine.util.render.Render2D;
13
import org.apache.commons.io.FileUtils;
14
15
import java.io.File;
16
import java.io.IOException;
17
import java.io.InputStream;
18
import java.util.Arrays;
19
20
import static nicotine.util.Common.mc;
21
22
public class GIF extends HUDMod {
23
    private File gifDir;
24
25
    private GIFEntry entryToDraw;
26
    private long prevTime = System.nanoTime();
27
28
    public static DropDownOption images;
29
    private SliderOption fps = new SliderOption("FPS", 30, 1, 60);
30
    private final ClickOption refresh = new ClickOption("Refresh") {
31
        @Override
32
        public void click() {
33
            images.modes = gifDir.list();
34
35
            for (int i = 0; i < images.modes.length; i++)
36
                if (images.modes[i].equals(images.value))
37
                    return;
38
39
            if (images.modes.length > 0) {
40
                images.value = images.modes[0];
41
                images.select();
42
            } else
43
                images.value = "";
44
        }
45
    };
46
47
    public GIF() {
48
        super(ModCategory.HUD, "GIF");
49
        this.addOptions(Arrays.asList(images, fps, refresh));
50
    }
51
52
    @Override
53
    public void init() {
54
        gifDir = new File("nicotine");
55
56
        if (!gifDir.exists())
57
            gifDir.mkdir();
58
59
        File outputFile = new File("nicotine/blahaj.gif");
60
61
        if (!outputFile.exists()) {
62
            InputStream inputStream = GIF.class.getClassLoader().getResourceAsStream("gifs/blahaj.gif");
63
            try {
64
                FileUtils.copyInputStreamToFile(inputStream, outputFile);
65
            } catch (IOException e) {
66
                e.printStackTrace();
67
            }
68
        }
69
70
        images = new DropDownOption("Images", gifDir.list()) {
71
            @Override
72
            public void select() {
73
                Render2D.extractGIFImages(new File(String.format("nicotine/%s", this.value)));
74
            }
75
        };
76
77
        EventBus.register(GuiRenderBeforeEvent.class, event -> {
78
            if (!this.enabled || images.modes.length == 0)
79
                return true;
80
81
            if (Render2D.gifImages.isEmpty()) {
82
                images.select();
83
            }
84
85
            if (System.nanoTime() - prevTime >= Math.pow(10, 9) / fps.value) {
86
                entryToDraw = Render2D.getGIFEntry();
87
                prevTime = System.nanoTime();
88
            }
89
90
            if (entryToDraw == null) {
91
                return true;
92
            }
93
94
            final int width = entryToDraw.nativeImage.getWidth();
95
            final int height = entryToDraw.nativeImage.getHeight();
96
97
            final int posX = (mc.getWindow().getGuiScaledWidth() / 2) - (width / 2);
98
            final int posY = mc.getWindow().getGuiScaledHeight() - 80 - height;
99
100
            event.drawContext.blit(RenderPipelines.GUI_TEXTURED, entryToDraw.identifier, posX, posY, 0.0F, 0.0F, width, height, width, height, width, height);
101
102
            return true;
103
        });
104
    }
105
}
106