From e15e825d3639edadd3f7e4be4bcaa8228b645f06 Mon Sep 17 00:00:00 2001 From: winterflyt <36+winterflyt@noreply.skidsolutions.xyz> Date: Mon, 30 Nov 2026 06:10:06 +0200 Subject: [PATCH] Upload files to "src/openonyx/render/group_i" --- .../render/group_i/ChinaHatRenderer.java | 391 ++++++++++++++++++ 1 file changed, 391 insertions(+) create mode 100644 src/openonyx/render/group_i/ChinaHatRenderer.java diff --git a/src/openonyx/render/group_i/ChinaHatRenderer.java b/src/openonyx/render/group_i/ChinaHatRenderer.java new file mode 100644 index 0000000..3388440 --- /dev/null +++ b/src/openonyx/render/group_i/ChinaHatRenderer.java @@ -0,0 +1,391 @@ +package openonyx.render.group_i; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.entity.Entity; +import net.minecraft.util.Vec3; +import openonyx.core.MinecraftAccess; +import openonyx.core.OnyxClient; +import openonyx.theme.internal.ColorUtils; +import org.lwjgl.opengl.GL11; + +public final class ChinaHatRenderer implements MinecraftAccess { + private static final int D = -1; + private static final float c = 2.0F; + private static final float a = 0.07F; + private static final float k = 0.14F; + private static final float g = (float) (Math.PI * 2); + private final int[] M; + private static final int L = 48; + private static final float j = 1.01F; + private static final float[] m; + private static final float h = 0.12F; + private static final int l = 8; + private boolean I; + private static final float d = 0.22F; + private static final int i = 48; + private static final float[] f; + private static final float H = 0.012F; + private static final float e = 1.35F; + + private static void i() { + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + } + + private void L(ChinaHatStyle chinaHatStyle) { + ChinaHatRenderer chinaHatRenderer1 = this; + + for (int kx = ix = 0; kx <= 48; kx = ix) { + int[] jx = chinaHatRenderer1.M; + int lx = ix; + int mx = L(chinaHatStyle, (float) (Math.PI * 2) * ix / 48.0F); + ix++; + jx[lx] = mx; + } + } + + private static void L(boolean bl) { + GlStateManager.pushMatrix(); + GlStateManager.disableTexture2D(); + GlStateManager.disableLighting(); + GlStateManager.disableFog(); + GlStateManager.enableBlend(); + i(); + GlStateManager.disableCull(); + GlStateManager.depthMask(false); + GlStateManager.shadeModel(7425); + if (bl) { + GlStateManager.disableDepth(); + } + + GL11.glEnable(2848); + GL11.glHint(3154, 4354); + } + + private void i(List list, ChinaHatStyle chinaHatStyle, Vec3 vec3) { + ChinaHatRenderer chinaHatRenderer1 = this; + Tessellator tessellator; + WorldRenderer worldRenderer = (tessellator = Tessellator.getInstance()).getWorldRenderer(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + int n = (int)(255.0F * chinaHatStyle.opacity() * 0.7F); + + for (HatPose hatPose : list) { + ChinaHatRendererPart2 chinaHatRendererPart2 = new ChinaHatRendererPart2(hatPose, vec3); + + int ix; + for (int o = ix = 0; o < 8; o = ++ix) { + float fx = ix / 8.0F; + float gx = (ix + 1) / 8.0F; + float hx = chinaHatStyle.radius() * L(fx); + float jx = chinaHatStyle.radius() * L(gx); + fx = chinaHatStyle.height() * d(fx); + gx = chinaHatStyle.height() * d(gx); + + for (int p = mx = 0; p < 48; p = mx) { + int kx = L(chinaHatRenderer1.M[mx], n); + int lx = L(chinaHatRenderer1.M[mx + 1], n); + chinaHatRendererPart2.L(worldRenderer, hx * m[mx], fx, hx * f[mx], kx); + chinaHatRendererPart2.L(worldRenderer, hx * m[mx + 1], fx, hx * f[mx + 1], lx); + chinaHatRendererPart2.L(worldRenderer, jx * m[mx + 1], gx, jx * f[mx + 1], lx); + float q = jx * m[mx]; + float r = f[mx]; + mx++; + chinaHatRendererPart2.L(worldRenderer, q, gx, jx * r, kx); + } + } + } + + tessellator.draw(); + } + + private static int L(ChinaHatStyle chinaHatStyle, float f, float g) { + gx = D(gx); + return L(L(L(chinaHatStyle, fx), -1, 0.35F * gx), (int)(255.0F * chinaHatStyle.opacity() * 0.8F * gx)); + } + + private static void D() { + GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0); + } + + private static int L(int i) { + return ix >> 24 & 0xFF; + } + + private void D(List list, ChinaHatStyle chinaHatStyle, Vec3 vec3) { + ChinaHatRenderer chinaHatRenderer1 = this; + Tessellator tessellator; + WorldRenderer worldRenderer = (tessellator = Tessellator.getInstance()).getWorldRenderer(); + GL11.glLineWidth(2.0F); + worldRenderer.begin(1, DefaultVertexFormats.POSITION_COLOR); + int q = (int)(255.0F * chinaHatStyle.opacity()); + float fx = chinaHatStyle.radius(); + float gx = chinaHatStyle.height() * d(0.0F); + Iterator iterator = list.iterator(); + + label36: + while (true) { + for (Iterator iterator1 = iterator; iterator1.hasNext(); iterator1 = iterator) { + HatPose hatPose = (HatPose)iterator.next(); + ChinaHatRendererPart2 chinaHatRendererPart2 = new ChinaHatRendererPart2(hatPose, vec3); + + for (int s = n = 0; s < 48; s = n) { + chinaHatRendererPart2.L(worldRenderer, fx * m[n], gx, fx * f[n], L(chinaHatRenderer1.M[n], q)); + float v = fx * m[n + 1]; + float w = fx * f[n + 1]; + int x = chinaHatRenderer1.M[n + 1]; + n++; + chinaHatRendererPart2.L(worldRenderer, v, gx, w, L(x, q)); + } + + if (chinaHatStyle.trail()) { + float o; + float r = (float)Math.cos(o = hatPose.phase() + chinaHatStyle.sweep()); + float hx = (float)Math.sin(o); + int p = L(L(chinaHatStyle, o), q); + + int ix; + for (int t = ix = 0; t < 8; t = ix) { + float jx = ix / 8.0F; + float kx = (ix + 1) / 8.0F; + float lx = chinaHatStyle.radius() * L(jx) * 1.01F; + float mx = chinaHatStyle.radius() * L(kx) * 1.01F; + jx = chinaHatStyle.height() * (d(jx) + 0.012F); + kx = chinaHatStyle.height() * (d(kx) + 0.012F); + chinaHatRendererPart2.L(worldRenderer, lx * r, jx, lx * hx, p); + float u = mx * r; + ix++; + chinaHatRendererPart2.L(worldRenderer, u, kx, mx * hx, p); + } + continue label36; + } + } + + tessellator.draw(); + GL11.glLineWidth(1.0F); + return; + } + } + + private static float D(float f) { + float gx = fx; + float hx = fx = Math.clamp(1.0F - gx, 0.0F, 1.0F); + return hx * hx * (3.0F - 2.0F * fx); + } + + private static void L(WorldRenderer worldRenderer, double d, double e, double f, int i) { + worldRenderer.pos(dx, ex, fx).color(d(ix, 16), d(ix, 8), d(ix, 0), L(ix)).endVertex(); + } + + private static int L(int i, int j, float f) { + int kx = d(ix, 16) + (int)((d(jx, 16) - d(ix, 16)) * fx); + int lx = d(ix, 8) + (int)((d(jx, 8) - d(ix, 8)) * fx); + jx = d(ix, 0) + (int)((d(jx, 0) - d(ix, 0)) * fx); + return ix & 0xFF000000 | kx << 16 | lx << 8 | jx; + } + + private void d(List list, ChinaHatStyle chinaHatStyle, Vec3 vec3) { + Tessellator tessellator; + WorldRenderer worldRenderer = (tessellator = Tessellator.getInstance()).getWorldRenderer(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + + for (HatPose hatPose : list) { + ChinaHatRendererPart2 chinaHatRendererPart2 = new ChinaHatRendererPart2(hatPose, vec3); + float s = hatPose.phase() + chinaHatStyle.sweep(); + + int ix; + for (int u = ix = 0; u < 48; u = ++ix) { + float fx = s - chinaHatStyle.trailSpan() * ix / 48.0F; + float q = s - chinaHatStyle.trailSpan() * (ix + 1) / 48.0F; + int jx = L(chinaHatStyle, fx, ix / 48.0F); + int kx = L(chinaHatStyle, q, (ix + 1) / 48.0F); + if (L(jx) != 0 || L(kx) != 0) { + float gx = (float)Math.cos(fx); + fx = (float)Math.sin(fx); + float hx = (float)Math.cos(q); + float r = (float)Math.sin(q); + + int lx; + for (int t = lx = 0; t < 8; t = lx) { + float mx = lx / 8.0F; + float n = (lx + 1) / 8.0F; + float o = chinaHatStyle.radius() * L(mx) * 1.01F; + float p = chinaHatStyle.radius() * L(n) * 1.01F; + mx = chinaHatStyle.height() * (d(mx) + 0.012F); + n = chinaHatStyle.height() * (d(n) + 0.012F); + chinaHatRendererPart2.L(worldRenderer, o * gx, mx, o * fx, jx); + chinaHatRendererPart2.L(worldRenderer, p * gx, n, p * fx, jx); + chinaHatRendererPart2.L(worldRenderer, p * hx, n, p * r, kx); + float v = o * hx; + lx++; + chinaHatRendererPart2.L(worldRenderer, v, mx, o * r, kx); + } + } + } + } + + tessellator.draw(); + } + + private static float d(float f) { + return (float)Math.pow(fx, 1.35F) + 0.12F * (float)Math.pow(1.0F - fx, 5.0); + } + + private static int d(int i, int j) { + return ix >> jx & 0xFF; + } + + public ChinaHatRenderer() { + int jx = 113 & 63; + super(); + this.I = true; + int[] ix = new int[jx]; + boolean bl = true; + this.M = ix; + } + + private static int L(ChinaHatStyle chinaHatStyle, float f) { + ChinaHatStyle chinaHatStyle1 = chinaHatStyle; + switch (chinaHatStyle1.colors()) { + case STATIC: + while (false) { + } + + return chinaHatStyle1.color(); + case GRADIENT: + return L(chinaHatStyle1.color(), chinaHatStyle1.secondColor(), 0.5F - 0.5F * (float)Math.cos(fx + chinaHatStyle1.colorPhase())); + case RAINBOW: + float[] gx; + return ColorUtils.hsvToArgb( + (gx = ColorUtils.toRgbFloats(chinaHatStyle1.color()))[0] + (float)Math.toDegrees(fx + chinaHatStyle1.colorPhase()), gx[1], gx[2], 255 + ); + default: + throw new MatchException(null, null); + } + } + + public void L(float f, List list, ChinaHatStyle chinaHatStyle) { + ChinaHatRenderer chinaHatRenderer1 = this; + if (chinaHatRenderer1.I && !list.isEmpty()) { + Entity entity; + if ((entity = mc.getRenderViewEntity()) != null) { + Vec3 vec3 = new Vec3( + entity.prevPosX + (entity.posX - entity.prevPosX) * fx, + entity.prevPosY + (entity.posY - entity.prevPosY) * fx, + entity.prevPosZ + (entity.posZ - entity.prevPosZ) * fx + ); + + try { + chinaHatRenderer1.L(chinaHatStyle); + L(chinaHatStyle.throughWalls()); + chinaHatRenderer1.i(list, chinaHatStyle, vec3); + if (chinaHatStyle.trail()) { + chinaHatRenderer1.d(list, chinaHatStyle, vec3); + } + + if (chinaHatStyle.glow()) { + chinaHatRenderer1.L(list, chinaHatStyle, vec3); + } + + chinaHatRenderer1.D(list, chinaHatStyle, vec3); + L(); + } catch (Throwable throwable) { + chinaHatRenderer1.I = false; + OnyxClient.LOGGER.warn("ChinaHat renderer has been disabled after a render failure", throwable); + } + } + } + } + + private static int L(int i, int j) { + return Math.clamp(jx, 0, 255) << 24 | ix & 16777215; + } + + private static float L(float f) { + return 1.0F - fx; + } + + static { + float[] hx = new float[49]; + boolean bl = true; + m = hx; + hx = new float[49]; + bl = true; + f = hx; + + int ix; + for (int jx = ix = 0; jx <= 48; jx = ix) { + float fx = (float) (Math.PI * 2) * ix / 48.0F; + m[ix] = (float)Math.cos(fx); + hx = f; + int kx = ix; + float gx = (float)Math.sin(fx); + ix++; + hx[kx] = gx; + } + } + + public void d() { + this.I = true; + } + + private void L(List list, ChinaHatStyle chinaHatStyle, Vec3 vec3) { + ChinaHatRenderer chinaHatRenderer1 = this; + Tessellator tessellator; + WorldRenderer worldRenderer = (tessellator = Tessellator.getInstance()).getWorldRenderer(); + D(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + int o = (int)(255.0F * chinaHatStyle.opacity() * 0.22F); + float p = chinaHatStyle.radius(); + float fx = chinaHatStyle.height() * d(0.0F); + float gx = chinaHatStyle.radius() * 1.07F; + float hx = chinaHatStyle.radius() * L(0.14F); + float ix = chinaHatStyle.height() * d(0.14F); + + for (HatPose hatPose : list) { + ChinaHatRendererPart2 chinaHatRendererPart2 = new ChinaHatRendererPart2(hatPose, vec3); + + for (int q = n = 0; q < 48; q = n) { + int jx = L(chinaHatRenderer1.M[n], o); + int kx = L(chinaHatRenderer1.M[n + 1], o); + int lx = L(jx, 0); + int mx = L(kx, 0); + chinaHatRendererPart2.L(worldRenderer, p * m[n], fx, p * f[n], jx); + chinaHatRendererPart2.L(worldRenderer, p * m[n + 1], fx, p * f[n + 1], kx); + chinaHatRendererPart2.L(worldRenderer, gx * m[n + 1], fx, gx * f[n + 1], mx); + chinaHatRendererPart2.L(worldRenderer, gx * m[n], fx, gx * f[n], lx); + chinaHatRendererPart2.L(worldRenderer, p * m[n], fx, p * f[n], jx); + chinaHatRendererPart2.L(worldRenderer, p * m[n + 1], fx, p * f[n + 1], kx); + chinaHatRendererPart2.L(worldRenderer, hx * m[n + 1], ix, hx * f[n + 1], mx); + float r = hx * m[n]; + float s = f[n]; + n++; + chinaHatRendererPart2.L(worldRenderer, r, ix, hx * s, lx); + } + } + + tessellator.draw(); + i(); + } + + private static void L() { + GL11.glDisable(2848); + GlStateManager.shadeModel(7424); + GlStateManager.depthMask(true); + GlStateManager.enableDepth(); + GlStateManager.enableCull(); + GlStateManager.disableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.blendFunc(770, 771); + GlStateManager.disableFog(); + GlStateManager.enableLighting(); + GlStateManager.enableTexture2D(); + GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.popMatrix(); + } +}