aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/themes/textures/TickableTexture.java
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-04-16 14:51:58 +0900
committerWyvest <45589059+Wyvest@users.noreply.github.com>2022-04-16 14:51:58 +0900
commitcf164be0c8f43c3d1387c9c9f7ae73c2cf1b3a02 (patch)
treec3f2cbfe39919941b9bb04f6de2e3cec103509fd /src/main/java/io/polyfrost/oneconfig/themes/textures/TickableTexture.java
parentf10f1165a7c2ea88ce7bb265d51b52eeaa64d8f8 (diff)
downloadOneConfig-cf164be0c8f43c3d1387c9c9f7ae73c2cf1b3a02.tar.gz
OneConfig-cf164be0c8f43c3d1387c9c9f7ae73c2cf1b3a02.tar.bz2
OneConfig-cf164be0c8f43c3d1387c9c9f7ae73c2cf1b3a02.zip
merge rendering files + remove themes
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/themes/textures/TickableTexture.java')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/themes/textures/TickableTexture.java90
1 files changed, 0 insertions, 90 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/themes/textures/TickableTexture.java b/src/main/java/io/polyfrost/oneconfig/themes/textures/TickableTexture.java
deleted file mode 100644
index 5fe1242..0000000
--- a/src/main/java/io/polyfrost/oneconfig/themes/textures/TickableTexture.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package io.polyfrost.oneconfig.themes.textures;
-
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.Gui;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.texture.DynamicTexture;
-import net.minecraft.util.ResourceLocation;
-
-import javax.imageio.ImageIO;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import static io.polyfrost.oneconfig.themes.Themes.getActiveTheme;
-import static io.polyfrost.oneconfig.themes.Themes.themeLog;
-
-@SuppressWarnings("unused")
-public class TickableTexture {
- private final int framesToSkip;
- private final BufferedImage image;
- private final int sizeX, sizeY, frames;
- private final ThemeElement thisElement;
- private final ResourceLocation location;
- private int tick;
- private int tick2;
-
- public TickableTexture(ThemeElement element) throws IOException {
- thisElement = element;
- InputStream inputStream = getActiveTheme().getResource(element.location);
- image = ImageIO.read(inputStream);
- location = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation(element.location, new DynamicTexture(image));
- sizeX = image.getWidth();
- sizeY = image.getHeight();
- frames = sizeY / sizeX;
- int frametime;
- try {
- JsonObject jsonObject = new JsonParser().parse(new InputStreamReader(getActiveTheme().getResource(element.location + ".json"))).getAsJsonObject();
- frametime = jsonObject.get("frametime").getAsInt();
- if (frametime == 0) {
- frametime = 1;
- themeLog.warn("You cannot have a frame tick time of 0. This will mean there is no animation as it will happen impossibly fast. Defaulting to 1, as we assume you wanted it fast.");
- }
- } catch (Exception e) {
- themeLog.error("failed to load metadata for tickable texture (" + element.location + "). Setting default (5)");
- frametime = 5;
- }
- framesToSkip = frametime;
- }
-
- public void draw(int x, int y) {
- GlStateManager.enableBlend();
- GlStateManager.color(1f, 1f, 1f, 1f);
- Minecraft.getMinecraft().getTextureManager().bindTexture(location);
- if (tick < frames) {
- Gui.drawModalRectWithCustomSizedTexture(x, y, 0, (tick * sizeX), sizeX, sizeX, sizeX, sizeX);
- tick2++;
- if (tick2 == framesToSkip) {
- tick2 = 0;
- tick++;
- }
- }
- if (tick == frames) {
- tick = 0;
- }
- GlStateManager.disableBlend();
- }
-
- public BufferedImage getImage() {
- return image;
- }
-
- public int getFrameTime() {
- return framesToSkip;
- }
-
- public int getSizeX() {
- return sizeX;
- }
-
- public int getSizeY() {
- return sizeY;
- }
-
- public ThemeElement getElement() {
- return thisElement;
- }
-}