diff --git a/src/main/java/fox/spiteful/avaritia/compat/ticon/InfinityIcons.java b/src/main/java/fox/spiteful/avaritia/compat/ticon/InfinityIcons.java index ed07608..4f2aee2 100644 --- a/src/main/java/fox/spiteful/avaritia/compat/ticon/InfinityIcons.java +++ b/src/main/java/fox/spiteful/avaritia/compat/ticon/InfinityIcons.java @@ -10,6 +10,8 @@ import javax.imageio.ImageIO; import org.apache.logging.log4j.Level; +import codechicken.lib.math.MathHelper; + import fox.spiteful.avaritia.Lumberjack; import net.minecraft.client.Minecraft; @@ -24,15 +26,26 @@ public class InfinityIcons extends TConTextureResourcePackBase { super(Tonkers.infinityMetalName); } - protected BufferedImage loadInfinityImage() { - ResourceLocation res = new ResourceLocation("avaritia", "textures/items/ticoninfinity.png"); - try { - InputStream stream = Minecraft.getMinecraft().getResourceManager().getResource(res).getInputStream(); - infinityImage = ImageIO.read(stream); - } catch (Exception err) { - Lumberjack.log(Level.WARN, "Unable to load overlay image for Infinity tool parts"); + protected void loadInfinityImage() { + if (infinityImage == null) { + ResourceLocation res = new ResourceLocation("avaritia", "textures/items/ticoninfinity.png"); + try { + InputStream stream = Minecraft.getMinecraft().getResourceManager().getResource(res).getInputStream(); + infinityImage = ImageIO.read(stream); + } catch (Exception err) { + Lumberjack.log(Level.WARN, "Unable to load overlay image for Infinity tool parts"); + } + } + } + protected InputStream loadInfinityAnimation() { + InputStream stream = null; + ResourceLocation res = new ResourceLocation("avaritia", "textures/items/ticoninfinitymeta.png.mcmeta"); + try { + stream = Minecraft.getMinecraft().getResourceManager().getResource(res).getInputStream(); + } catch (Exception err) { + Lumberjack.log(Level.WARN, "Unable to load animation data for Infinity tool parts"); } - return infinityImage; + return stream; } @Override @@ -48,29 +61,132 @@ public class InfinityIcons extends TConTextureResourcePackBase { image = temp; } + int c, a, i, inf; + int r, g, b; + int fr,fg,fb; + double l, frac; + + int left = w-1; + int right = 0; + int top = h-1; + int bottom = 0; + boolean anyOpaque = false; + int opaquecount = 0; + + // get the extents of the opaque part of the image + for (int y = 0; y w*h*0.3) { + sx1 = MathHelper.floor_double(iw*0.25); + sx2 = MathHelper.floor_double(iw*0.75); + sy1 = MathHelper.floor_double(ih*0.25); + sy2 = MathHelper.floor_double(ih*0.75); + } + + Graphics2D graphics = infinity.createGraphics(); + graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + //graphics.drawImage(infinityImage, left, top, opaqueSquare, opaqueSquare, null); + + graphics.drawImage(infinityImage, left, top, left+opaqueSquare, top+opaqueSquare, sx1,sy1,sx2,sy2, null); } //ok, now do stuff with it - int[] data = new int[w*h]; + /*int[] data = new int[w*h]; infinity.getRGB(0, 0, w, h, data, 0, w); - image.setRGB(0, 0, w, h, data, 0, w); + image.setRGB(0, 0, w, h, data, 0, w);*/ - return image; + int frames = 9; + + BufferedImage framesimage = new BufferedImage(w,h*frames, BufferedImage.TYPE_INT_ARGB); + + double brighten = 1.3; + for (int y = 0; y