diff --git a/src/openonyx/render/group_z/JumpCirclePoint.java b/src/openonyx/render/group_z/JumpCirclePoint.java new file mode 100644 index 0000000..a60b660 --- /dev/null +++ b/src/openonyx/render/group_z/JumpCirclePoint.java @@ -0,0 +1,6 @@ +package openonyx.render.group_z; + +import net.minecraft.util.Vec3; + +public record JumpCirclePoint(Vec3 position, long time) { +} diff --git a/src/openonyx/render/group_z/JumpCircleRenderer.java b/src/openonyx/render/group_z/JumpCircleRenderer.java new file mode 100644 index 0000000..9eac532 --- /dev/null +++ b/src/openonyx/render/group_z/JumpCircleRenderer.java @@ -0,0 +1,249 @@ +package openonyx.render.group_z; + +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.ResourceLocation; +import net.minecraft.util.Vec3; +import openonyx.core.MinecraftAccess; +import openonyx.core.OnyxClient; +import openonyx.features.render.JumpCirclesMode; +import openonyx.render.group_e.FontFamily; +import openonyx.render.group_e.FontFamilyMode; +import openonyx.render.group_e.GlyphFont; +import openonyx.render.group_e.GlyphFontData; +import openonyx.render.group_e.TargetHudTextSettingsWeightMode; +import org.lwjgl.opengl.GL11; + +public final class JumpCircleRenderer implements MinecraftAccess { + private static final String h = " "; + private boolean l; + private static final float I = 0.49F; + private static final ResourceLocation RESOURCE_LOCATION = new ResourceLocation("onyx", "textures/effect/jump_circle.png"); + private final JumpCircleShader jumpCircleShader; + private static final float f = 0.35F; + private static final float H = (float) (Math.PI * 2); + private static final float e = 0.015F; + + private static int L(JumpCircleStyle jumpCircleStyle, float f) { + return Math.clamp((int)(255.0F * jumpCircleStyle.opacity() * Math.max(0.0F, fx)), 0, 255) << 24 | jumpCircleStyle.color() & 16777215; + } + + private static void L(boolean bl) { + GlStateManager.pushMatrix(); + GlStateManager.enableTexture2D(); + GlStateManager.disableLighting(); + GlStateManager.disableFog(); + GlStateManager.disableAlpha(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(770, 1); + GlStateManager.disableCull(); + GlStateManager.depthMask(false); + GlStateManager.shadeModel(7425); + if (bl) { + GlStateManager.disableDepth(); + } + } + + public void L(float f, List list, JumpCircleStyle jumpCircleStyle) { + JumpCircleRenderer jumpCircleRenderer1 = this; + if (jumpCircleRenderer1.l && !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 + ); + long lx = System.currentTimeMillis(); + + try { + jumpCircleRenderer1.jumpCircleShader.L(list, jumpCircleStyle, lx); + L(jumpCircleStyle.throughWalls()); + jumpCircleRenderer1.d(list, jumpCircleStyle, vec3, lx); + if (jumpCircleStyle.mode() == JumpCirclesMode.TEXT) { + jumpCircleRenderer1.L(list, jumpCircleStyle, vec3, lx); + } + + d(); + } catch (Throwable throwable) { + jumpCircleRenderer1.l = false; + OnyxClient.LOGGER.warn("JumpCircles renderer has been disabled after a render failure", throwable); + } + } + } + } + + private void d(List list, JumpCircleStyle jumpCircleStyle, Vec3 vec3, long l) { + mc.getTextureManager().bindTexture(RESOURCE_LOCATION); + Tessellator tessellator; + WorldRenderer worldRenderer = (tessellator = Tessellator.getInstance()).getWorldRenderer(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); + Iterator iterator; + Iterator iterator1 = iterator = list.iterator(); + + while (iterator1.hasNext()) { + JumpCirclePoint jumpCirclePoint; + float fx; + float g; + if ((g = L(jumpCircleStyle, fx = L(jumpCirclePoint = (JumpCirclePoint)iterator.next(), jumpCircleStyle, lx)) / 0.49F) <= 0.0F) { + iterator1 = iterator; + } else { + int i = L(jumpCircleStyle, L(fx)); + Vec3 vec31 = jumpCirclePoint.position().subtract(vec3); + iterator1 = iterator; + L(worldRenderer, vec31, -g, -g, 0.0F, 0.0F, i); + L(worldRenderer, vec31, -g, g, 0.0F, 1.0F, i); + L(worldRenderer, vec31, g, g, 1.0F, 1.0F, i); + L(worldRenderer, vec31, g, -g, 1.0F, 0.0F, i); + } + } + + tessellator.draw(); + } + + private static void L(WorldRenderer worldRenderer, Vec3 vec3, float f, float g, float h, float i, int j) { + worldRenderer.pos(vec3.xCoord + fx, vec3.yCoord + 0.015F, vec3.zCoord + g).tex(hx, i).color(L(j, 16), L(j, 8), L(j, 0), L(j, 24)).endVertex(); + } + + private static float L(float f) { + return 1.0F - fx; + } + + private static int L(int i, int j) { + return i >> j & 0xFF; + } + + private void L(List list, JumpCircleStyle jumpCircleStyle, Vec3 vec3, long l) { + String string; + if (!(string = jumpCircleStyle.text().trim()).isEmpty() && !(jumpCircleStyle.radius() <= 0.0F)) { + GlyphFont glyphFont = FontFamily.L(FontFamilyMode.PT36, TargetHudTextSettingsWeightMode.BOLD); + string = new StringBuilder().insert(0, string).append(" ").toString(); + + int i; + for (int x = i = 0; x < string.length(); x = i) { + glyphFont.d(string.charAt(i++)); + } + + if ((i = glyphFont.L()) != -1) { + GlStateManager.bindTexture(i); + float u = jumpCircleStyle.textHeight() / glyphFont.d(); + float fx; + if (!((fx = jumpCircleStyle.radius() - jumpCircleStyle.textHeight() * 1.35F) <= 0.0F)) { + float g; + if (!((g = glyphFont.L(string) * u) <= 0.0F)) { + float hx = (float) (Math.PI * 2) * fx; + int j = Math.max(1, Math.round(hx / g)); + g = hx / (j * g); + Iterator iterator; + Iterator iterator1 = iterator = list.iterator(); + + while (iterator1.hasNext()) { + float k; + float s; + JumpCirclePoint jumpCirclePoint; + if ((s = L(k = L(jumpCirclePoint = (JumpCirclePoint)iterator.next(), jumpCircleStyle, lx))) <= 0.0F) { + iterator1 = iterator; + } else if ((k = L(jumpCircleStyle, k) / jumpCircleStyle.radius()) <= 0.0F) { + iterator1 = iterator; + } else { + float m = u * k; + k = fx * k; + int t; + GL11.glColor4f(L(t = L(jumpCircleStyle, s), 16) / 255.0F, L(t, 8) / 255.0F, L(t, 0) / 255.0F, L(t, 24) / 255.0F); + GL11.glBegin(7); + Vec3 vec31 = jumpCirclePoint.position().subtract(vec3); + hx = (float)Math.toRadians(jumpCircleStyle.spin() * L(jumpCirclePoint, lx)); + float n = 0.0F; + + int o; + int p; + for (int v = o = 0; v < j; v = ++o) { + for (int w = p = 0; w < string.length(); w = p) { + GlyphFontData glyphFontData; + if (!(glyphFontData = glyphFont.d(string.charAt(p))).L()) { + float q = glyphFontData.width() * m; + float r = n + (glyphFontData.bearingX() * m + q / 2.0F) * g; + L(vec31, glyphFontData, hx + r / k, k, q / 2.0F, glyphFontData.bearingY() * m, glyphFontData.height() * m); + } + + float y = glyphFontData.advance() * m; + p++; + n += y * g; + } + } + + GL11.glEnd(); + iterator1 = iterator; + } + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.resetColor(); + } + } + } + } + } + + private static void d() { + GlStateManager.shadeModel(7424); + GlStateManager.depthMask(true); + GlStateManager.enableDepth(); + GlStateManager.enableCull(); + GlStateManager.enableAlpha(); + 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(); + } + + private static void L(Vec3 vec3, double d, double e, double f, double g, float h, float i) { + GL11.glTexCoord2f(hx, i); + GL11.glVertex3d(vec3.xCoord + fx * d - g * ex, vec3.yCoord + 0.015F, vec3.zCoord + fx * ex + g * d); + } + + private static float L(JumpCircleStyle jumpCircleStyle, float f) { + return jumpCircleStyle.radius() * (1.0F - (float)Math.pow(1.0F - fx, 4.0)); + } + + private static void L(Vec3 vec3, GlyphFontData glyphFontData, float f, float g, float h, float i, float j) { + double d = Math.cos(fx); + double ex = Math.sin(fx); + double k; + double lx = (k = g - i) - j; + L(vec3, d, ex, k, -hx, glyphFontData.u0(), glyphFontData.v0()); + L(vec3, d, ex, lx, -hx, glyphFontData.u0(), glyphFontData.v1()); + L(vec3, d, ex, lx, hx, glyphFontData.u1(), glyphFontData.v1()); + L(vec3, d, ex, k, hx, glyphFontData.u1(), glyphFontData.v0()); + } + + private static float L(JumpCirclePoint jumpCirclePoint, JumpCircleStyle jumpCircleStyle, long l) { + return Math.clamp((float)(lx - jumpCirclePoint.time()) / (float)jumpCircleStyle.lifetime(), 0.0F, 1.0F); + } + + public JumpCircleRenderer() { + int i = --1; + super(); + this.jumpCircleShader = new JumpCircleShader(); + this.l = (boolean)i; + } + + private static float L(JumpCirclePoint jumpCirclePoint, long l) { + return (float)(lx - jumpCirclePoint.time()) / 1000.0F; + } + + public void L() { + this.l = true; + } +} diff --git a/src/openonyx/render/group_z/JumpCircleShader.java b/src/openonyx/render/group_z/JumpCircleShader.java new file mode 100644 index 0000000..6a1a083 --- /dev/null +++ b/src/openonyx/render/group_z/JumpCircleShader.java @@ -0,0 +1,259 @@ +package openonyx.render.group_z; + +import java.util.List; +import net.minecraft.util.Vec3; +import openonyx.core.MinecraftAccess; +import openonyx.render.PostProcessor; +import openonyx.render.PostProcessorData; +import openonyx.render.WorldToScreen; +import openonyx.render.group_p.ShaderProgram; + +final class JumpCircleShader implements MinecraftAccess { + private static final float K = 4.0F; + private final double[] B; + private static final float C = 0.05F; + private static final int J = 2; + private float D; + private static final int c = 8; + private final float[] a; + private static final float k = 1.03F; + private static final float g = 0.12F; + private static final int M = 16; + private static final double L = 0.06; + private float j; + private boolean m; + private float h; + private final Vec3[] vec3s; + private static final float I = 0.3F; + private ShaderProgram shaderProgram; + private boolean i; + private final float[] f; + private float H; + private static final float e = 0.16F; + + private int L(List list, JumpCircleStyle jumpCircleStyle, long l) { + JumpCircleShader jumpCircleShader1 = this; + Vec3 vec3 = WorldToScreen.getVec3(); + float fx = WorldToScreen.L() * 0.5F; + jumpCircleShader1.h = jumpCircleShader1.j = Float.MAX_VALUE; + jumpCircleShader1.D = -Float.MAX_VALUE; + jumpCircleShader1.H = -Float.MAX_VALUE; + jumpCircleShader1.i = false; + int ix = 0; + + int jx; + for (int n = jx = list.size() - 1; n >= 0 && ix < 8; n = --jx) { + JumpCirclePoint jumpCirclePoint = (JumpCirclePoint)list.get(jx); + float gx = Math.clamp((float)(l - jumpCirclePoint.time()) / (float)jumpCircleStyle.lifetime(), 0.0F, 1.0F); + float hx; + if (!((hx = 1.0F - gx) <= 0.0F) + && !((gx = jumpCircleStyle.radius() * (1.0F - (float)Math.pow(1.0F - gx, 4.0))) < 0.05F) + && jumpCircleShader1.L(jumpCirclePoint.position(), gx)) { + Vec3 vec31; + double d = Math.max((vec31 = jumpCirclePoint.position().subtract(vec3)).lengthVector(), 0.1); + float mx; + if (!((mx = Math.min((float)(gx * fx / d), 0.3F)) <= 0.0F)) { + int kx = ix * 4; + jumpCircleShader1.f[kx] = (float)vec31.xCoord; + jumpCircleShader1.f[kx + 1] = (float)vec31.yCoord; + jumpCircleShader1.f[kx + 2] = (float)vec31.zCoord; + jumpCircleShader1.f[kx + 3] = gx; + jumpCircleShader1.a[kx] = hx; + jumpCircleShader1.a[kx + 1] = mx; + jumpCircleShader1.a[kx + 2] = 0.0F; + int o = kx + 3; + ix++; + jumpCircleShader1.a[o] = 0.0F; + } + } + } + + return ix; + } + + private PostProcessorData L(int i, JumpCircleStyle jumpCircleStyle) { + JumpCircleShader jumpCircleShader1 = this; + if (jumpCircleShader1.i) { + return null; + } + + if (jumpCircleShader1.j > jumpCircleShader1.D) { + return null; + } + + int kx = PostProcessor.d(); + int jx = PostProcessor.L(); + if (kx > 0 && jx > 0) { + float fx = 0.0F; + + int l; + for (int p = l = 0; p < ix; p = l) { + int q = l * 4 + 1; + l++; + fx = Math.max(fx, jumpCircleShader1.a[q]); + } + + float hx = jumpCircleStyle.glassWarp() * 0.16F * fx * 1.3F; + float gx = jumpCircleStyle.glassBlur() * 0.12F * fx; + ix = (int)Math.ceil(Math.max(hx * kx, gx * jx)) + 1; + int o = (int)Math.floor(jumpCircleShader1.j * kx) - 2; + int n = (int)Math.floor(jumpCircleShader1.h * jx) - 2; + l = (int)Math.ceil(jumpCircleShader1.D * kx) + 2; + int mx = (int)Math.ceil(jumpCircleShader1.H * jx) + 2; + return new PostProcessorData(o, n, l - o, mx - n, ix).L(kx, jx); + } else { + return null; + } + } + + private boolean L(Vec3 vec3, float f) { + JumpCircleShader jumpCircleShader1 = this; + if (jumpCircleShader1.i) { + return true; + } + + Vec3 vec32 = WorldToScreen.getVec3(); + Vec3 vec31 = WorldToScreen.getVec32(); + fx *= 1.03F; + int ix = 0; + + for (int r = jx = 0; r < 16; r = ++jx) { + double d = jx * (Math.PI / 8); + Vec3 vec33 = vec3.addVector(Math.cos(d) * fx, 0.0, Math.sin(d) * fx); + jumpCircleShader1.vec3s[jx] = vec33; + jumpCircleShader1.B[jx] = vec33.subtract(vec32).dotProduct(vec31); + if (jumpCircleShader1.B[jx] >= 0.06) { + ix++; + } + } + + if (ix == 0) { + return false; + } + + float kx = Float.MAX_VALUE; + float o = Float.MAX_VALUE; + float gx = -Float.MAX_VALUE; + float p = -Float.MAX_VALUE; + + for (int q = l = 0; q < 16; q = ++l) { + int mx = (l + 1) % 16; + boolean bl1 = jumpCircleShader1.B[l] >= 0.06; + boolean bl = jumpCircleShader1.B[mx] >= 0.06; + if (bl1) { + float[] hx; + if ((hx = jumpCircleShader1.L(jumpCircleShader1.vec3s[l])) == null) { + return true; + } + + kx = Math.min(kx, hx[0]); + gx = Math.max(gx, hx[0]); + o = Math.min(o, hx[1]); + p = Math.max(p, hx[1]); + } + + if (bl1 != bl) { + double ex = (jumpCircleShader1.B[l] - 0.06) / (jumpCircleShader1.B[l] - jumpCircleShader1.B[mx]); + float[] n; + if ((n = jumpCircleShader1.L(jumpCircleShader1.vec3s[l].add(jumpCircleShader1.vec3s[mx].subtract(jumpCircleShader1.vec3s[l]).scale(ex)))) == null) { + return true; + } + + kx = Math.min(kx, n[0]); + gx = Math.max(gx, n[0]); + o = Math.min(o, n[1]); + p = Math.max(p, n[1]); + } + } + + if (!(gx < 0.0F) && !(kx > 1.0F) && !(p < 0.0F) && !(o > 1.0F)) { + jumpCircleShader1.j = Math.min(jumpCircleShader1.j, kx); + jumpCircleShader1.D = Math.max(jumpCircleShader1.D, gx); + jumpCircleShader1.h = Math.min(jumpCircleShader1.h, o); + jumpCircleShader1.H = Math.max(jumpCircleShader1.H, p); + return true; + } else { + return false; + } + } + + private float[] L(Vec3 vec3) { + float[] fx; + if ((fx = WorldToScreen.L(vec3, 1.0F, 1.0F)) == null) { + this.i = true; + return null; + } else { + float[] gx = new float[2]; + boolean bl = true; + gx[0] = Math.clamp(fx[0], -4.0F, 4.0F); + gx[1] = Math.clamp(1.0F - fx[1], -4.0F, 4.0F); + return gx; + } + } + + void L(List list, JumpCircleStyle jumpCircleStyle, long l) { + JumpCircleShader jumpCircleShader1 = this; + if (jumpCircleStyle.glass() && !list.isEmpty()) { + if (!(jumpCircleStyle.glassBlur() <= 0.0F) || !(jumpCircleStyle.glassWarp() <= 0.0F)) { + if (PostProcessor.L() && WorldToScreen.L()) { + int ix; + if ((ix = jumpCircleShader1.L(list, jumpCircleStyle, l)) != 0) { + PostProcessorData postProcessorData; + if ((postProcessorData = jumpCircleShader1.L(ix, jumpCircleStyle)) != null || jumpCircleShader1.i) { + if (!jumpCircleShader1.m) { + jumpCircleShader1.m = true; + jumpCircleShader1.shaderProgram = ShaderProgram.load("onyx_jump_glass", "onyx_post", "onyx_jump_glass"); + } + + if (jumpCircleShader1.shaderProgram != null && jumpCircleShader1.shaderProgram.isLoaded()) { + Vec3 vec3 = WorldToScreen.getVec32(); + Vec3 vec32 = WorldToScreen.getVec33(); + Vec3 vec33; + Vec3 vec31 = (vec33 = new Vec3(-vec32.xCoord, -vec32.yCoord, -vec32.zCoord)).crossProduct(vec3); + PostProcessor.L(jumpCircleShader1.shaderProgram, shaderProgram -> { + int lx = 0; + shaderProgramx.setUniform1i("uCount", ix); + shaderProgramx.setUniform1f("uBlur", jumpCircleStyle.glassBlur() * 0.12F); + shaderProgramx.setUniform1f("uWarp", jumpCircleStyle.glassWarp() * 0.16F); + shaderProgramx.setUniform3f("uForward", (float)vec3.xCoord, (float)vec3.yCoord, (float)vec3.zCoord); + shaderProgramx.setUniform3f("uRight", (float)vec33.xCoord, (float)vec33.yCoord, (float)vec33.zCoord); + shaderProgramx.setUniform3f("uUp", (float)vec31.xCoord, (float)vec31.yCoord, (float)vec31.zCoord); + shaderProgramx.setUniform2f("uTanHalf", 1.0F / WorldToScreen.d(), 1.0F / WorldToScreen.L()); + + for (int jx = 0; lx < ix; lx = jx) { + int kx = jx * 4; + shaderProgramx.setUniform4f("uLensA[" + jx + "]", this.f[kx], this.f[kx + 1], this.f[kx + 2], this.f[kx + 3]); + String string = new StringBuilder().insert(0, "uLensB[").append(jx).append("]").toString(); + float fx = this.a[kx]; + float gx = this.a[kx + 1]; + float hx = this.a[kx + 2]; + int mx = kx + 3; + jx++; + shaderProgramx.setUniform4f(string, fx, gx, hx, this.a[mx]); + } + }, postProcessorData); + } + } + } + } + } + } + } + + JumpCircleShader() { + int ix = 91 & 52; + super(); + float[] gx = new float[32]; + boolean bl3 = true; + this.f = gx; + float[] fx = new float[32]; + boolean bl2 = true; + this.a = fx; + Vec3[] vec3sx = new Vec3[ix]; + boolean bl = true; + this.vec3s = vec3sx; + double[] d = new double[16]; + boolean bl1 = true; + this.B = d; + } +} diff --git a/src/openonyx/render/group_z/JumpCircleStyle.java b/src/openonyx/render/group_z/JumpCircleStyle.java new file mode 100644 index 0000000..842152a --- /dev/null +++ b/src/openonyx/render/group_z/JumpCircleStyle.java @@ -0,0 +1,49 @@ +package openonyx.render.group_z; + +import openonyx.features.render.JumpCirclesMode; + +public record JumpCircleStyle( + JumpCirclesMode mode, + int color, + float opacity, + float radius, + long lifetime, + float spin, + String text, + float textHeight, + boolean throughWalls, + boolean glass, + float glassBlur, + float glassWarp +) { + public static String decrypt(String string) { + String string1 = string; + int k = --3 << --3 ^ 7; + String string2; + int n = (string2 = string1).length(); + char[] e = new char[n]; + boolean bl = true; + int i; + int m = i = n - 1; + char[] c = e; + byte d = 8; + k = m; + byte b = 117; + + while (k >= 0) { + int l = i; + int j = string2.charAt(i); + i--; + c[l] = (char)(j ^ b); + if (i < 0) { + break; + } + + j = i--; + c[j] = (char)(string2.charAt(j) ^ d); + k = i; + } + + return new String(c); + } +}