From 8c6508551e14fdf222ccc82b5f44666de78d7304 Mon Sep 17 00:00:00 2001 From: winterflyt <36+winterflyt@noreply.skidsolutions.xyz> Date: Mon, 30 Nov 2026 06:09:31 +0200 Subject: [PATCH] Upload files to "src/openonyx/render/group_g" --- .../render/group_g/CapeTextureLoader.java | 94 ++++++++++++ src/openonyx/render/group_g/FitMode.java | 33 ++++ src/openonyx/render/group_g/ImageUtils.java | 144 ++++++++++++++++++ src/openonyx/render/group_g/LogoTexture.java | 88 +++++++++++ 4 files changed, 359 insertions(+) create mode 100644 src/openonyx/render/group_g/CapeTextureLoader.java create mode 100644 src/openonyx/render/group_g/FitMode.java create mode 100644 src/openonyx/render/group_g/ImageUtils.java create mode 100644 src/openonyx/render/group_g/LogoTexture.java diff --git a/src/openonyx/render/group_g/CapeTextureLoader.java b/src/openonyx/render/group_g/CapeTextureLoader.java new file mode 100644 index 0000000..d1029a1 --- /dev/null +++ b/src/openonyx/render/group_g/CapeTextureLoader.java @@ -0,0 +1,94 @@ +package openonyx.render.group_g; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.function.Consumer; +import javax.imageio.ImageIO; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.util.ResourceLocation; +import openonyx.core.MinecraftAccess; +import openonyx.core.OnyxClient; +import org.apache.logging.log4j.Logger; + +public final class CapeTextureLoader implements MinecraftAccess { + private static final ResourceLocation RESOURCE_LOCATION = new ResourceLocation("onyx", "capes/source"); + private static final ExecutorService EXECUTOR_SERVICE = Executors.newSingleThreadExecutor(runnable -> { + Thread thread = new Thread(runnable, "onyx-cape-loader"); + thread.setDaemon(true); + return thread; + }); + private static final ResourceLocation RESOURCE_LOCATION2 = new ResourceLocation("onyx", "capes/local"); + + public static void d(BufferedImage bufferedImage, Consumer consumer) { + mc.addScheduledTask(() -> { + mc.getTextureManager().deleteTexture(RESOURCE_LOCATION2); + mc.getTextureManager().loadTexture(RESOURCE_LOCATION2, new DynamicTexture(bufferedImage)); + consumer.accept(RESOURCE_LOCATION2); + }); + } + + private CapeTextureLoader() { + } + + public static ResourceLocation L(BufferedImage bufferedImage) { + mc.getTextureManager().deleteTexture(RESOURCE_LOCATION); + mc.getTextureManager().loadTexture(RESOURCE_LOCATION, new DynamicTexture(bufferedImage)); + return RESOURCE_LOCATION; + } + + public static void L(Consumer consumer, Consumer consumer1) { + Consumer consumer2 = consumer; + + try { + bufferedImage = LogoTexture.L(); + } catch (IOException iOException) { + OnyxClient.LOGGER.warn("CapeChanger: failed to draw the default cape", iOException); + consumer1.accept("Can't draw the default cape"); + return; + } + + d(bufferedImage, consumer2); + } + + public static void d(String string, Consumer consumer, Consumer consumer1) { + if (!string.isEmpty()) { + EXECUTOR_SERVICE.submit(() -> { + String string2 = string; + + BufferedImage bufferedImage; + try { + bufferedImage = ImageIO.read(new File(string2)); + } catch (IOException iOException) { + Logger logger = OnyxClient.LOGGER; + Object[] objects = new Object[2]; + boolean bl = true; + objects[0] = string2; + objects[1] = iOException; + logger.warn("CapeChanger: failed to read '{}'", objects); + consumer1.accept("Can't read that file"); + return; + } + + if (bufferedImage == null) { + consumer1.accept("Not a readable PNG"); + } else { + BufferedImage bufferedImage1 = bufferedImage; + mc.addScheduledTask(() -> consumer.accept(bufferedImage1)); + } + }); + } + } + + public static void L(BufferedImage bufferedImage, FitMode fitMode, int i, double d, double e, double f, Consumer consumer) { + EXECUTOR_SERVICE.submit(() -> { + try { + d(ImageUtils.L(bufferedImage, fitMode, i, d, e, f), consumer); + } catch (RuntimeException runtimeException) { + OnyxClient.LOGGER.warn("CapeChanger: failed to compose the cape", runtimeException); + } + }); + } +} diff --git a/src/openonyx/render/group_g/FitMode.java b/src/openonyx/render/group_g/FitMode.java new file mode 100644 index 0000000..af4ca0d --- /dev/null +++ b/src/openonyx/render/group_g/FitMode.java @@ -0,0 +1,33 @@ +package openonyx.render.group_g; + +import openonyx.history.DisplayNamed; + +public enum FitMode implements DisplayNamed { + AUTO("Auto"), + FILL("Fill"), + TEXTURE("Texture"), + FIT("Fit"), + STRETCH("Stretch"); + + private final String H; + + @Override + public String getDisplayName() { + return this.H; + } + + private static FitMode[] L() { + FitMode[] fitModes = new FitMode[5]; + boolean bl = true; + fitModes[0] = AUTO; + fitModes[1] = FIT; + fitModes[2] = FILL; + fitModes[3] = STRETCH; + fitModes[4] = TEXTURE; + return fitModes; + } + + FitMode(String string1) { + this.H = string1; + } +} diff --git a/src/openonyx/render/group_g/ImageUtils.java b/src/openonyx/render/group_g/ImageUtils.java new file mode 100644 index 0000000..ff14835 --- /dev/null +++ b/src/openonyx/render/group_g/ImageUtils.java @@ -0,0 +1,144 @@ +package openonyx.render.group_g; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.image.BufferedImage; +import net.optifine.player.CapeUtils; + +public final class ImageUtils { + private static final int M = 17; + private static final int L = 8; + public static final int j = 1; + public static final int m = 32; + private static final int h = 22; + public static final int l = 1; + public static final int I = 10; + public static final int d = 12; + private static final int i = 32; + private static final float f = 0.55F; + public static final int H = 64; + public static final int e = 16; + + public static boolean L(BufferedImage bufferedImage) { + BufferedImage bufferedImage1 = bufferedImage; + int ix = bufferedImage1.getWidth(); + int jx = bufferedImage1.getHeight(); + return ix % 64 == 0 && jx % 32 == 0 ? ix / 64 == jx / 32 : false; + } + + public static BufferedImage L(BufferedImage bufferedImage, FitMode fitMode, int i, double d, double e, double f) { + BufferedImage bufferedImage1 = bufferedImage; + if (L(fitMode, bufferedImage1) == FitMode.TEXTURE) { + return CapeUtils.parseCape(bufferedImage1); + } + + int lx = L(bufferedImage1); + int jx = 10 * lx; + int k = 16 * lx; + BufferedImage bufferedImage2; + Graphics2D graphics2D; + Graphics2D graphics2D1 = graphics2D = (bufferedImage2 = new BufferedImage(64 * lx, 32 * lx, 2)).createGraphics(); + graphics2D1.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + graphics2D1.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + Color color; + graphics2D1.setPaint(color = new Color(ix | 0xFF000000, true)); + graphics2D1.fillRect(0, 0, 22 * lx, 17 * lx); + graphics2D1.setPaint(L(color)); + graphics2D1.fillRect(12 * lx, 1 * lx, jx, k); + double[] g = L(bufferedImage1, L(fitMode, bufferedImage1), jx, k, dx, ex, fx); + graphics2D.setClip(1 * lx, 1 * lx, jx, k); + graphics2D.drawImage( + bufferedImage1, + 1 * lx + (int)Math.round(g[0]), + 1 * lx + (int)Math.round(g[1]), + Math.max(1, (int)Math.round(g[2])), + Math.max(1, (int)Math.round(g[3])), + null + ); + graphics2D.dispose(); + return bufferedImage2; + } + + public static double[] L(BufferedImage bufferedImage, FitMode fitMode, double d, double e, double f, double g, double h) { + double jx; + double s; + if (fitMode == FitMode.STRETCH) { + double ix = dx; + jx = ex; + s = ix; + } else { + double k = dx / bufferedImage.getWidth(); + double lx = ex / bufferedImage.getHeight(); + double mx = fitMode == FitMode.FILL ? Math.max(k, lx) : Math.min(k, lx); + double n = bufferedImage.getWidth() * mx; + jx = bufferedImage.getHeight() * mx; + s = n; + } + + double o = s * fx; + jx *= fx; + double p = (dx - o) / 2.0 + g * dx; + double q = (ex - jx) / 2.0 + hx * ex; + double[] r = new double[4]; + boolean bl = true; + r[0] = p; + r[1] = q; + r[2] = o; + r[3] = jx; + return r; + } + + public static String decrypt(String string) { + String string1 = string; + int mx = --5 << 3 ^ 5; + int n = 3 << 3 ^ 5; + String string2; + int p = (string2 = string1).length(); + char[] dx = new char[p]; + boolean bl = true; + int jx; + int o = jx = p - 1; + char[] c = dx; + byte b = 36; + int k = o; + int ix = mx; + + while (k >= 0) { + n = jx; + int lx = string2.charAt(jx); + jx--; + c[n] = (char)(lx ^ ix); + if (jx < 0) { + break; + } + + lx = jx--; + c[lx] = (char)(string2.charAt(lx) ^ b); + k = jx; + } + + return new String(c); + } + + private ImageUtils() { + } + + private static Color L(Color color) { + return new Color((int)(color.getRed() * 0.55F), (int)(color.getGreen() * 0.55F), (int)(color.getBlue() * 0.55F)); + } + + private static int L(BufferedImage bufferedImage) { + BufferedImage bufferedImage1 = bufferedImage; + int ix = (int)Math.ceil(Math.max(bufferedImage1.getWidth() / 10.0, bufferedImage1.getHeight() / 16.0)); + return Math.max(8, Math.min(32, ix)); + } + + public static FitMode L(FitMode fitMode, BufferedImage bufferedImage) { + if (fitMode != FitMode.AUTO) { + return fitMode; + } else { + return L(bufferedImage) ? FitMode.TEXTURE : FitMode.FIT; + } + } +} diff --git a/src/openonyx/render/group_g/LogoTexture.java b/src/openonyx/render/group_g/LogoTexture.java new file mode 100644 index 0000000..50ecd03 --- /dev/null +++ b/src/openonyx/render/group_g/LogoTexture.java @@ -0,0 +1,88 @@ +package openonyx.render.group_g; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import javax.imageio.ImageIO; +import net.minecraft.util.ResourceLocation; +import openonyx.core.MinecraftAccess; + +public final class LogoTexture implements MinecraftAccess { + private static final int D = 8; + private static final int c = 128; + private static final int a = 12; + private static final float k = 0.7F; + private static final ResourceLocation RESOURCE_LOCATION = new ResourceLocation("onyx", "textures/gui/logo.png"); + private static final int M = 176; + private static final int L = 8; + private static final Color COLOR = new Color(-15987695, true); + private static final int m = 96; + private static final Color COLOR2 = new Color(587202559, true); + private static final int l = 136; + private static final int I = 80; + private static final Color COLOR3 = new Color(-16119282, true); + private static final int i = 256; + private static final Color COLOR4 = new Color(-14474196, true); + private static final int H = 8; + private static final int e = 512; + + private LogoTexture() { + } + + public static BufferedImage L() throws IOException { + InputStream inputStream = mc.getResourceManager().getResource(RESOURCE_LOCATION).getInputStream(); + + BufferedImage bufferedImage; + try { + bufferedImage = ImageIO.read(inputStream); + } catch (Throwable throwable1) { + if (inputStream != null) { + try { + inputStream.close(); + } catch (Throwable throwable) { + throwable1.addSuppressed(throwable); + throw throwable1; + } + + throw throwable1; + } + + throw throwable1; + } + + BufferedImage bufferedImage1; + if (inputStream != null) { + bufferedImage1 = bufferedImage; + inputStream.close(); + } else { + bufferedImage1 = bufferedImage; + } + + if (bufferedImage1 == null) { + throw new IOException("logo.png is not a readable PNG"); + } + + bufferedImage1 = new BufferedImage(512, 256, 2); + Graphics2D graphics2D = bufferedImage1.createGraphics(); + graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + graphics2D.setPaint(new GradientPaint(0.0F, 0.0F, COLOR4, 0.0F, 136.0F, COLOR)); + graphics2D.fillRect(0, 0, 176, 136); + graphics2D.setPaint(COLOR3); + graphics2D.fillRect(96, 8, 80, 128); + graphics2D.setPaint(COLOR2); + graphics2D.setStroke(new BasicStroke(8.0F)); + graphics2D.drawRect(20, 20, 56, 104); + int ix; + int j = Math.round((float)(ix = Math.round(56.0F)) * bufferedImage.getHeight() / bufferedImage.getWidth()); + graphics2D.drawImage(bufferedImage, 8 + (80 - ix) / 2, 8 + (128 - j) / 2, ix, j, null); + graphics2D.dispose(); + return bufferedImage1; + } +}