diff --git a/src/openonyx/render/PostProcessor.java b/src/openonyx/render/PostProcessor.java new file mode 100644 index 0000000..b138eb6 --- /dev/null +++ b/src/openonyx/render/PostProcessor.java @@ -0,0 +1,195 @@ +package openonyx.render; + +import java.nio.ByteBuffer; +import java.util.function.Consumer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.client.shader.Framebuffer; +import openonyx.core.MinecraftAccess; +import openonyx.core.OnyxClient; +import openonyx.render.group_p.ShaderProgram; +import org.lwjgl.opengl.GL11; + +public final class PostProcessor implements MinecraftAccess { + private static int I = -1; + private static int d; + private static boolean i = true; + private static final int f = 5889; + private static int H; + private static final int e = 5888; + + public static void L(ShaderProgram shaderProgram, Consumer consumer, PostProcessorData postProcessorData) { + if (L() && shaderProgram != null && shaderProgram.isLoaded()) { + Minecraft minecraft = MinecraftAccess.mc; + Framebuffer framebuffer = MinecraftAccess.mc.getFramebuffer(); + boolean bl = OpenGlHelper.isFramebufferEnabled() && framebuffer != null; + int ix = bl ? framebuffer.framebufferWidth : minecraft.displayWidth; + int j = bl ? framebuffer.framebufferHeight : minecraft.displayHeight; + if (ix > 0 && j > 0) { + PostProcessorData postProcessorData1 = postProcessorData == null ? null : postProcessorData.L(ix, j); + if (postProcessorData == null || postProcessorData1 != null) { + postProcessorData = postProcessorData1 == null ? null : postProcessorData1.L(postProcessorData1.reach()).L(ix, j); + + try { + GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); + d(ix, j); + GlStateManager.bindTexture(I); + int k; + if (postProcessorData == null) { + GL11.glCopyTexSubImage2D(3553, 0, 0, 0, 0, 0, ix, j); + k = ix; + } else { + GL11.glCopyTexSubImage2D( + 3553, + 0, + postProcessorData.x(), + postProcessorData.y(), + postProcessorData.x(), + postProcessorData.y(), + postProcessorData.width(), + postProcessorData.height() + ); + k = ix; + } + + L(k, j); + if (bl) { + framebuffer.bindFramebuffer(false); + } + + GlStateManager.bindTexture(I); + shaderProgram.use(); + shaderProgram.setUniform1i("Sampler0", 0); + shaderProgram.setUniform2f("uResolution", ix, j); + consumer.accept(shaderProgram); + L(postProcessorData1, ix, j); + d(); + } catch (Throwable throwable) { + L(throwable); + } + } + } + } + } + + public static int d() { + Framebuffer framebuffer = MinecraftAccess.mc.getFramebuffer(); + return OpenGlHelper.isFramebufferEnabled() && framebuffer != null ? framebuffer.framebufferWidth : MinecraftAccess.mc.displayWidth; + } + + public static void L(ShaderProgram shaderProgram, Consumer consumer) { + L(shaderProgram, consumer, null); + } + + private PostProcessor() { + } + + public static int L() { + Framebuffer framebuffer = MinecraftAccess.mc.getFramebuffer(); + return OpenGlHelper.isFramebufferEnabled() && framebuffer != null ? framebuffer.framebufferHeight : MinecraftAccess.mc.displayHeight; + } + + private static void L(Throwable throwable) { + i = false; + + try { + L(); + } catch (Throwable throwable1) { + } + + OnyxClient.LOGGER.warn("Post-processing unavailable, effects disabled for this session", throwable); + } + + public static boolean L() { + return i && OpenGlHelper.shadersSupported; + } + + private static void L(PostProcessorData postProcessorData, int i, int j) { + PostProcessorData postProcessorData1 = postProcessorData; + float fx = 0.0F; + float g = 0.0F; + float h = 1.0F; + float k = 1.0F; + if (postProcessorData1 != null) { + fx = (float)postProcessorData1.x() / ix; + g = (float)postProcessorData1.y() / j; + h = (float)(postProcessorData1.x() + postProcessorData1.width()) / ix; + k = (float)(postProcessorData1.y() + postProcessorData1.height()) / j; + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glBegin(7); + GL11.glTexCoord2f(fx, g); + GL11.glVertex2f(fx, g); + GL11.glTexCoord2f(h, g); + GL11.glVertex2f(h, g); + GL11.glTexCoord2f(h, k); + GL11.glVertex2f(h, k); + GL11.glTexCoord2f(fx, k); + GL11.glVertex2f(fx, k); + GL11.glEnd(); + } + + private static void d(int i, int j) { + if (I == -1 || H != ix || d != j) { + L(); + I = TextureUtil.glGenTextures(); + GlStateManager.bindTexture(I); + GL11.glTexImage2D(3553, 0, 32856, ix, j, 0, 6408, 5121, (ByteBuffer)null); + GL11.glTexParameteri(3553, 10241, 9729); + GL11.glTexParameteri(3553, 10240, 9729); + GL11.glTexParameteri(3553, 10242, 33071); + GL11.glTexParameteri(3553, 10243, 33071); + int k; + if ((k = GL11.glGetError()) != 0) { + throw new IllegalStateException(new StringBuilder().insert(0, "post target allocation failed, GL error ").append(k).toString()); + } + + H = ix; + d = j; + } + } + + private static void L(int i, int j) { + GlStateManager.matrixMode(5889); + GlStateManager.pushMatrix(); + GlStateManager.loadIdentity(); + GL11.glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); + GlStateManager.matrixMode(5888); + GlStateManager.pushMatrix(); + GlStateManager.loadIdentity(); + GlStateManager.disableBlend(); + GlStateManager.disableAlpha(); + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + GlStateManager.disableLighting(); + GlStateManager.enableTexture2D(); + GlStateManager.viewport(0, 0, ix, j); + } + + private static void d() { + ShaderProgram.unbind(); + GlStateManager.matrixMode(5889); + GlStateManager.popMatrix(); + GlStateManager.matrixMode(5888); + GlStateManager.popMatrix(); + GlStateManager.depthMask(true); + GlStateManager.enableDepth(); + GlStateManager.enableAlpha(); + GlStateManager.enableLighting(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.resetColor(); + } + + private static void L() { + if (I != -1) { + TextureUtil.deleteTexture(I); + I = -1; + } + + H = 0; + d = 0; + } +} diff --git a/src/openonyx/render/PostProcessorData.java b/src/openonyx/render/PostProcessorData.java new file mode 100644 index 0000000..d4dc0d0 --- /dev/null +++ b/src/openonyx/render/PostProcessorData.java @@ -0,0 +1,16 @@ +package openonyx.render; + +public record PostProcessorData(int x, int y, int width, int height, int reach) { + public PostProcessorData L(int i, int j) { + PostProcessorData postProcessorData1 = this; + int k = Math.max(0, postProcessorData1.x); + int l = Math.max(0, postProcessorData1.y); + i = Math.min(i, postProcessorData1.x + postProcessorData1.width); + j = Math.min(j, postProcessorData1.y + postProcessorData1.height); + return i > k && j > l ? new PostProcessorData(k, l, i - k, j - l, postProcessorData1.reach) : null; + } + + public PostProcessorData L(int i) { + return new PostProcessorData(this.x - i, this.y - i, this.width + i * 2, this.height + i * 2, this.reach); + } +} diff --git a/src/openonyx/render/Render2D.java b/src/openonyx/render/Render2D.java new file mode 100644 index 0000000..a98444c --- /dev/null +++ b/src/openonyx/render/Render2D.java @@ -0,0 +1,821 @@ +package openonyx.render; + +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.util.ArrayDeque; +import java.util.Deque; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import openonyx.core.MinecraftAccess; +import openonyx.render.group_e.FontFamily; +import openonyx.render.group_e.FontStyle; +import openonyx.render.group_e.GlyphFont; +import openonyx.render.group_e.GlyphFontData; +import openonyx.render.group_p.ShaderProgram; +import openonyx.theme.AlphaLevels; +import openonyx.theme.ThemeManager; +import openonyx.theme.ThemeSupport_058; +import openonyx.theme.internal.ColorUtils; +import openonyx.theme.internal.Hct; +import openonyx.theme.internal.TonalPalette; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.glu.GLU; + +public final class Render2D implements MinecraftAccess { + private static final int P = 64; + private float V; + private static final float R = 7.0F; + private static ShaderProgram shaderProgram; + private static final float t = 0.72F; + private static final float b = 0.99F; + private static final float E = 40.0F; + private static ShaderProgram shaderProgram2; + private static final float G = 8.0F; + private static final float A = 0.5F; + private static final int K = -1; + private static final FloatBuffer FLOAT_BUFFER = BufferUtils.createFloatBuffer(3); + private final FloatStack floatStack; + private static final float J = 8.0F; + private static final float D = 8.0F; + private static final IntBuffer INT_BUFFER = BufferUtils.createIntBuffer(16); + private static ShaderProgram shaderProgram3; + private static final float[] k; + private static final int g = 7425; + private static final float M = 0.70710677F; + private static final long L = System.nanoTime(); + private final FloatStack floatStack2; + private static final int m = 24; + private static final int h = 7424; + private static final FloatBuffer FLOAT_BUFFER2 = BufferUtils.createFloatBuffer(16); + private boolean I; + private static final float d = 0.88F; + private static final FloatBuffer FLOAT_BUFFER3 = BufferUtils.createFloatBuffer(16); + private final Deque deque; + private static final float H = (float) (Math.PI * 2); + private float e; + + public float getIconWidth(String string, float f) { + return FontFamily.L().L(string) * (f / 16.0F); + } + + public Render2D() { + int i = 3 & 5; + super(); + this.floatStack = new FloatStack(); + this.floatStack2 = new FloatStack(); + this.deque = new ArrayDeque<>(); + this.e = 1.0F; + this.V = 1.0F; + this.I = (boolean)i; + } + + public void drawTextTop(FontStyle fontStyle, String string, float f, float g, int i) { + this.drawText(fontStyle, string, f, gx + fontStyle.i() - 7.0F * fontStyle.L(), i); + } + + private void d(String string, float f, float g, float h, int i) { + this.pushMatrix(); + GlStateManager.translate(f, gx, 0.0F); + GlStateManager.scale(hx, hx, 1.0F); + this.L(FontFamily.L(), string, i); + this.popMatrix(); + } + + public void popAlpha() { + this.e = this.floatStack.pop(); + } + + public void L(float f, float g, float h, float i, float j, float k, float l, int m) { + if (!(kx <= 0.0F)) { + this.L(f, gx + l, hx, i, j, j, j, j, kx, kx * 2.0F, mx, mx, mx, mx); + } + } + + public void drawTextVCentered(FontStyle fontStyle, String string, float f, float g, int i) { + this.drawText(fontStyle, string, f, this.centerTextY(fontStyle, gx), i); + } + + public float centerTextY(FontStyle fontStyle, float f) { + return f + fontStyle.i() / 2.0F - 7.0F * fontStyle.L(); + } + + static { + float[] f = new float[16]; + boolean bl = true; + f[0] = 1.0F; + f[1] = 0.0F; + f[2] = -1.0F; + f[3] = 0.0F; + f[4] = 0.0F; + f[5] = 1.0F; + f[6] = 0.0F; + f[7] = -1.0F; + f[8] = 0.70710677F; + f[9] = 0.70710677F; + f[10] = 0.70710677F; + f[11] = -0.70710677F; + f[12] = -0.70710677F; + f[13] = 0.70710677F; + f[14] = -0.70710677F; + f[15] = -0.70710677F; + k = f; + } + + public void rect(float f, float g, float h, float i, int j) { + this.roundedRect(f, gx, hx, i, 0.0F, j); + } + + public void popMatrix() { + GlStateManager.popMatrix(); + this.V = this.floatStack2.pop(); + } + + public void L(ResourceLocation resourceLocation, float f, float g, float h, float i, float j, float k, float l, float m, int n, int o) { + this.L(resourceLocation, f, gx, hx, i, j, kx, l, mx, n, o, -1); + } + + private int d(int i) { + return this.e >= 1.0F ? i : ColorUtils.withAlpha(i, ColorUtils.alpha(i) / 255.0F * this.e); + } + + public void drawTextRight(FontStyle fontStyle, String string, float f, float g, int i) { + this.drawText(fontStyle, string, f - this.getTextWidth(fontStyle, string), gx, i); + } + + private static void D(float f, float g, float h, float i, int j) { + GL11.glColor4f((j >> 16 & 0xFF) / 255.0F, (j >> 8 & 0xFF) / 255.0F, (j & 0xFF) / 255.0F, (j >>> 24) / 255.0F); + GL11.glTexCoord2f(f - hx, gx - i); + GL11.glVertex2f(f, gx); + } + + public void pushAlpha(float f) { + this.floatStack.push(this.e); + this.e = Math.clamp(this.e * f, 0.0F, 1.0F); + } + + public void pushMatrix() { + this.floatStack2.push(this.V); + GlStateManager.pushMatrix(); + } + + public float getTextWidth(FontStyle fontStyle, String string) { + return fontStyle.L().L(string) * fontStyle.L(); + } + + public void pushScissor(float f, float g, float h, float i) { + int[] j = L(f, gx, f + hx, gx + i); + int[] kx; + if ((kx = this.deque.peek()) != null) { + j = L(j, kx); + } + + this.deque.push(j); + L(j); + } + + public void L(float f, float g, float h, float i, float j, int k, int l, int m, int n) { + this.L(f, gx, hx, i, j, j, j, j, kx, l, mx, n); + } + + private void L(float f, float g, float h, float i, float j, float k, float l, float m, float n, float o, int p, int q, int r, int s) { + if (!(hx <= 0.0F) && !(i <= 0.0F)) { + float tx = hx / 2.0F; + float u = i / 2.0F; + float v = f + tx; + float w = gx + u; + float x = f - o; + float y = gx - o; + f = f + hx + o; + gx = gx + i + o; + int z = this.d(p); + p = this.d(q); + q = this.d(r); + r = this.d(s); + ShaderProgram shaderProgramx = d(); + GlStateManager.disableTexture2D(); + Render2D render2D1; + if (shaderProgramx.isLoaded()) { + shaderProgramx.use(); + shaderProgramx.setUniform2f("uHalfExtents", tx, u); + shaderProgramx.setUniform4f( + "uCornerRadii", ThemeSupport_058.L(j, hx, i), ThemeSupport_058.L(kx, hx, i), ThemeSupport_058.L(l, hx, i), ThemeSupport_058.L(mx, hx, i) + ); + shaderProgramx.setUniform1f("uSoftness", n); + render2D1 = this; + shaderProgramx.setUniform1f("uPixel", this.V); + } else { + if (n != 0.0F) { + return; + } + + render2D1 = this; + } + + render2D1.L(x, y, f, gx, v, w, z, p, q, r); + ShaderProgram.unbind(); + } + } + + public void drawTextCentered(FontStyle fontStyle, String string, float f, float g, int i) { + this.drawText(fontStyle, string, f - this.getTextWidth(fontStyle, string) / 2.0F, gx, i); + } + + private static void L(int[] i) { + GL11.glEnable(3089); + GL11.glScissor(i[0], i[1], i[2], i[3]); + } + + private static int[] L(int[] i, int[] j) { + int kx = Math.max(i[0], j[0]); + int l = Math.max(i[1], j[1]); + int mx = Math.min(i[0] + i[2], j[0] + j[2]); + int n = Math.min(i[1] + i[3], j[1] + j[3]); + int[] o = new int[4]; + boolean bl = true; + o[0] = kx; + o[1] = l; + o[2] = Math.max(0, mx - kx); + o[3] = Math.max(0, n - l); + return o; + } + + private static float[] L(float f, float g) { + FLOAT_BUFFER.clear(); + GLU.gluProject(f, gx, 0.0F, FLOAT_BUFFER3, FLOAT_BUFFER2, INT_BUFFER, FLOAT_BUFFER); + float[] hx = new float[2]; + boolean bl = true; + hx[0] = FLOAT_BUFFER.get(0); + hx[1] = FLOAT_BUFFER.get(1); + return hx; + } + + private static ShaderProgram D() { + if (shaderProgram2 == null) { + shaderProgram2 = ShaderProgram.load("onyx_clouds"); + } + + return shaderProgram2; + } + + public void translate(float f, float g) { + GlStateManager.translate(f, gx, 0.0F); + } + + public float L(FontStyle fontStyle, float f) { + return f + 7.0F * fontStyle.L(); + } + + private static int L(int i) { + int j = i; + i = 1 + k.length / 2; + return ColorUtils.withAlpha(j, 1.0F - (float)Math.pow(1.0F - ColorUtils.alpha(j) / 255.0F, 1.0F / i)); + } + + public void drawText(FontStyle fontStyle, String string, float f, float g, int i) { + this.D(fontStyle, string, f, gx, this.d(i)); + } + + public void useTextCursor() { + if (this.I) { + CustomCursor.L(CustomCursorMode.TEXT); + } + } + + public void drawItem(ItemStack itemStack, float f, float g) { + if (itemStack != null && itemStack.getItem() != null) { + ShaderProgram.unbind(); + GlStateManager.enableTexture2D(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.enableDepth(); + GlStateManager.enableRescaleNormal(); + GlStateManager.enableAlpha(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + RenderHelper.enableGUIStandardItemLighting(); + GlStateManager.pushMatrix(); + GlStateManager.translate(f, gx, 0.0F); + mc.getRenderItem().renderItemAndEffectIntoGUI(itemStack, 0, 0); + GlStateManager.popMatrix(); + RenderHelper.disableStandardItemLighting(); + GlStateManager.disableRescaleNormal(); + GlStateManager.disableFog(); + GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GlStateManager.disableTexture2D(); + GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); + GL11.glTexEnvi(8960, 8704, 8448); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 771); + GlStateManager.disableAlpha(); + GlStateManager.disableDepth(); + GlStateManager.shadeModel(7425); + GlStateManager.resetColor(); + } + } + + private void L(GlyphFont glyphFont, String string, int i) { + if (!string.isEmpty() && i >>> 24 != 0) { + int j; + for (int n = j = 0; n < string.length(); n = j) { + glyphFont.d(string.charAt(j++)); + } + + if ((j = glyphFont.L()) != -1) { + GlStateManager.enableTexture2D(); + GlStateManager.bindTexture(j); + GL11.glColor4f((i >> 16 & 0xFF) / 255.0F, (i >> 8 & 0xFF) / 255.0F, (i & 0xFF) / 255.0F, (i >>> 24) / 255.0F); + GL11.glBegin(7); + float l = 0.0F; + + for (int mx = j = 0; mx < string.length(); mx = j) { + GlyphFontData glyphFontData; + if (!(glyphFontData = glyphFont.d(string.charAt(j))).L()) { + float f = l + glyphFontData.bearingX(); + float gx = 7.0F + glyphFontData.bearingY(); + float hx = f + glyphFontData.width(); + float kx = gx + glyphFontData.height(); + GL11.glTexCoord2f(glyphFontData.u0(), glyphFontData.v0()); + GL11.glVertex2f(f, gx); + GL11.glTexCoord2f(glyphFontData.u0(), glyphFontData.v1()); + GL11.glVertex2f(f, kx); + GL11.glTexCoord2f(glyphFontData.u1(), glyphFontData.v1()); + GL11.glVertex2f(hx, kx); + GL11.glTexCoord2f(glyphFontData.u1(), glyphFontData.v0()); + GL11.glVertex2f(hx, gx); + } + + j++; + l += glyphFontData.advance(); + } + + GL11.glEnd(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.resetColor(); + } + } + } + + private static ShaderProgram d() { + if (shaderProgram == null) { + shaderProgram = ShaderProgram.load("onyx_shape"); + } + + return shaderProgram; + } + + private static int[] L(float f, float g, float h, float i) { + FLOAT_BUFFER3.clear(); + FLOAT_BUFFER2.clear(); + INT_BUFFER.clear(); + GL11.glGetFloat(2982, FLOAT_BUFFER3); + GL11.glGetFloat(2983, FLOAT_BUFFER2); + GL11.glGetInteger(2978, INT_BUFFER); + float[] kx = L(f, gx); + float[] mx = L(hx, i); + int l = Math.round(Math.min(kx[0], mx[0])); + int o = Math.round(Math.min(kx[1], mx[1])); + int j = Math.round(Math.max(kx[0], mx[0])); + int n = Math.round(Math.max(kx[1], mx[1])); + int[] p = new int[4]; + boolean bl = true; + p[0] = l; + p[1] = o; + p[2] = Math.max(0, j - l); + p[3] = Math.max(0, n - o); + return p; + } + + public Render2D withoutCursor() { + this.I = false; + return this; + } + + public void I(float f, float g, float h, float i, float j, int k) { + Render2D render2D1 = this; + float l = hx - f; + float mx = i - gx; + float n; + if (!((n = (float)Math.sqrt(l * l + mx * mx)) < 1.0E-4F)) { + render2D1.pushMatrix(); + render2D1.transforms().d((f + hx) / 2.0F, (gx + i) / 2.0F); + render2D1.transforms().L((float)Math.atan2(mx, l)); + render2D1.roundedRect(-n / 2.0F, -j / 2.0F, n, j, Float.MAX_VALUE, kx); + render2D1.popMatrix(); + } + } + + public void i(float f, float g, float h, float i, float j, int k) { + if (!((j = ThemeSupport_058.L(j, hx, i)) <= 0.0F)) { + this.L(f - j, gx - j, hx + j * 2.0F, i + j * 2.0F, j * 2.0F, j * 2.0F, j * 2.0F, j * 2.0F, -j, 0.0F, kx, kx, kx, kx); + } + } + + public void drawPlayerHead(ResourceLocation resourceLocation, float f, float g, float h) { + this.L(resourceLocation, f, gx, hx, hx, 8.0F, 8.0F, 8.0F, 8.0F, 64, 64); + this.L(resourceLocation, f, gx, hx, hx, 40.0F, 8.0F, 8.0F, 8.0F, 64, 64); + } + + private void L(float f, float g, float h, float i, float j, float k, int l, int m, int n, int o) { + GL11.glBegin(7); + D(f, gx, j, kx, l); + D(f, i, j, kx, o); + D(hx, i, j, kx, n); + D(hx, gx, j, kx, mx); + GL11.glEnd(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.resetColor(); + } + + public void usePointerCursor() { + if (this.I) { + CustomCursor.L(CustomCursorMode.POINTER); + } + } + + public void I() { + } + + private void d(float f, float g, float h, float i, int j) { + int kx; + GL11.glColor4f(((kx = this.d(j)) >> 16 & 0xFF) / 255.0F, (kx >> 8 & 0xFF) / 255.0F, (kx & 0xFF) / 255.0F, (kx >>> 24) / 255.0F); + GL11.glTexCoord2f(hx, i); + GL11.glVertex2f(f, gx); + } + + public void beginFrame() { + boolean bl = true; + this.V = 1.0F / Math.max(1, new ScaledResolution(mc).getScaleFactor()); + GlStateManager.disableLighting(); + GlStateManager.disableFog(); + GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GlStateManager.disableTexture2D(); + GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); + GL11.glTexEnvi(8960, 8704, 8448); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 771); + GlStateManager.disableAlpha(); + GlStateManager.disableDepth(); + GlStateManager.shadeModel(7425); + } + + public String trimToWidth(FontStyle fontStyle, String string, float f) { + Render2D render2D1 = this; + if (render2D1.getTextWidth(fontStyle, string) <= f) { + return string; + } + + String string1 = "..."; + f -= render2D1.getTextWidth(fontStyle, string1); + int kx = 0; + int i = string.length(); + + while (kx < i) { + int j = (kx + i + 1) / 2; + if (render2D1.getTextWidth(fontStyle, string.substring(0, j)) <= f) { + kx = j; + } else { + i = j - 1; + } + } + + return new StringBuilder().insert(0, string.substring(0, kx)).append(string1).toString(); + } + + public void drawIcon(String string, float f, float g, float h, int i, float j) { + Render2D render2D1 = this; + GlyphFont glyphFont = FontFamily.L(); + hx /= 16.0F; + float kx = glyphFont.L(string) * hx; + f -= kx / 2.0F; + gx += hx * 1.0F; + i = render2D1.d(i); + if (j <= 0.0F) { + render2D1.d(string, f, gx, hx, i); + } else { + i = L(i); + j /= 2.0F; + + for (byte c = bx = 0; c < k.length; c = bx) { + float l = f + k[bx] * j; + float mx = gx + k[bx + 1] * j; + bx += 2; + render2D1.d(string, l, mx, hx, i); + } + + render2D1.d(string, f, gx, hx, i); + } + } + + private void D(FontStyle fontStyle, String string, float f, float g, int i) { + Render2D render2D1 = this; + float hx = fontStyle.L(); + render2D1.pushMatrix(); + GlStateManager.translate(f, gx, 0.0F); + GlStateManager.scale(hx, hx, 1.0F); + render2D1.L(fontStyle.L(), string, i); + render2D1.popMatrix(); + } + + public boolean blurRect(float f, float g, float h, float i, float j, int k) { + int l = BoxBlurShader.L(); + ShaderProgram shaderProgramx = L(); + if (l != -1 && shaderProgramx.isLoaded()) { + int[] mx = L(f, gx, f + hx, gx + i); + BoxBlurShader.d(mx[0], mx[1], mx[2], mx[3]); + GlStateManager.enableTexture2D(); + GlStateManager.bindTexture(l); + shaderProgramx.use(); + shaderProgramx.setUniform1i("Sampler0", 0); + shaderProgramx.setUniform2f("uHalfExtents", hx / 2.0F, i / 2.0F); + shaderProgramx.setUniform4f( + "uCornerRadii", ThemeSupport_058.L(j, hx, i), ThemeSupport_058.L(j, hx, i), ThemeSupport_058.L(j, hx, i), ThemeSupport_058.L(j, hx, i) + ); + shaderProgramx.setUniform2f("uResolution", mc.displayWidth, mc.displayHeight); + shaderProgramx.setUniform1f("uPixel", this.V); + shaderProgramx.setUniform1f("uTint", ColorUtils.alpha(kx) / 255.0F * 0.88F); + int n = this.d(kx | 0xFF000000); + this.L(f, gx, f + hx, gx + i, f + hx / 2.0F, gx + i / 2.0F, n, n, n, n); + ShaderProgram.unbind(); + return true; + } else { + this.roundedRect(f, gx, hx, i, j, kx); + return false; + } + } + + public void L(FontStyle fontStyle, String string, float f, float g, int i, float h) { + if (!(hx <= 0.0F) && !string.isEmpty() && i >>> 24 != 0) { + i = L(this.d(i)); + + byte bx; + for (byte c = bx = 0; c < k.length; c = bx) { + float j = f + k[bx] * hx; + float kx = k[bx + 1] * hx; + bx += 2; + this.D(fontStyle, string, j, gx + kx, i); + } + + this.D(fontStyle, string, f, gx, i); + } + } + + public void D() { + } + + public void drawEntityFace(EntityLivingBase entityLivingBase, float f, float g, int i) { + if (entityLivingBase != null && i > 0) { + ShaderProgram.unbind(); + GlStateManager.enableTexture2D(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.enableDepth(); + GlStateManager.enableAlpha(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.pushMatrix(); + GlStateManager.translate(f, gx, 0.0F); + GuiInventory.drawEntityOnScreen(0, 0, i, 0.0F, 0.0F, entityLivingBase); + GlStateManager.popMatrix(); + RenderHelper.disableStandardItemLighting(); + GlStateManager.disableRescaleNormal(); + GlStateManager.disableColorMaterial(); + GlStateManager.disableFog(); + GlStateManager.disableLighting(); + GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GlStateManager.disableTexture2D(); + GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); + GL11.glTexEnvi(8960, 8704, 8448); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 771); + GlStateManager.disableAlpha(); + GlStateManager.disableDepth(); + GlStateManager.shadeModel(7425); + GlStateManager.resetColor(); + } + } + + public void drawTextRightVCentered(FontStyle fontStyle, String string, float f, float g, int i) { + this.drawTextRight(fontStyle, string, f, this.centerTextY(fontStyle, gx), i); + } + + public void drawIcon(String string, float f, float g, float h, int i) { + this.drawIcon(string, f, gx, hx, i, 0.0F); + } + + public void L(ResourceLocation resourceLocation, float f, float g, float h, float i, float j, float k, float l, float m, int n, int o, int p) { + this.L(resourceLocation, f, gx, hx, i, j, kx, l, mx, n, o, p, TextureFilter.PIXELS); + } + + public void roundedRect(float f, float g, float h, float i, float j, int k) { + this.L(f, gx, hx, i, j, j, j, j, kx); + } + + private static ShaderProgram L() { + if (shaderProgram3 == null) { + shaderProgram3 = ShaderProgram.load("onyx_frost"); + } + + return shaderProgram3; + } + + public TransformStack transforms() { + return TransformStack.INSTANCE; + } + + public void L(float f, float g, float h, float i, float j, float k, float l, float m, int n) { + this.L(f, gx, hx, i, j, kx, l, mx, n, n, n, n); + } + + public void clearScissors() { + Render2D render2D1 = this; + + while (!render2D1.deque.isEmpty()) { + render2D1 = this; + this.popScissor(); + } + + ShaderProgram.unbind(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.resetColor(); + GlStateManager.shadeModel(7424); + GlStateManager.enableTexture2D(); + GlStateManager.enableDepth(); + GlStateManager.enableAlpha(); + GlStateManager.disableBlend(); + if (this.I) { + CustomCursor.L(); + } + } + + public void drawTextCenteredVCentered(FontStyle fontStyle, String string, float f, float g, int i) { + this.drawTextCentered(fontStyle, string, f, this.centerTextY(fontStyle, gx), i); + } + + public void shadow(float f, float g, float h, float i, float j, int k) { + float mx; + if (!((mx = AlphaLevels.L(kx)) <= 0.0F)) { + int l = ThemeManager.getPalette().shadow(); + this.L(f, gx, hx, i, j, mx, 0.0F, ThemeManager.withAlpha(l, 0.055F)); + this.L(f, gx, hx, i, j, mx * 1.5F, mx * 0.5F, ThemeManager.withAlpha(l, 0.075F)); + } + } + + public void popScissor() { + Render2D render2D1 = this; + if (!render2D1.deque.isEmpty()) { + render2D1.deque.pop(); + int[] i; + if ((i = render2D1.deque.peek()) == null) { + GL11.glDisable(3089); + } else { + L(i); + } + } + } + + public void L( + ResourceLocation resourceLocation, + float f, + float g, + float h, + float i, + float j, + float k, + float l, + float m, + int n, + int o, + int p, + TextureFilter textureFilter + ) { + p = this.d(p); + mc.getTextureManager().bindTexture(resourceLocation); + GlStateManager.enableTexture2D(); + int tx = textureFilter.L(); + GL11.glColor4f((p >> 16 & 0xFF) / 255.0F, (p >> 8 & 0xFF) / 255.0F, (p & 0xFF) / 255.0F, (p >>> 24) / 255.0F); + float u = l < n ? textureFilter.L() / n : 0.0F; + float q = mx < o ? textureFilter.L() / o : 0.0F; + float r = j / n + u; + float s = kx / o + q; + j = (j + l) / n - u; + kx = (kx + mx) / o - q; + GL11.glBegin(7); + GL11.glTexCoord2f(r, s); + GL11.glVertex2f(f, gx); + GL11.glTexCoord2f(r, kx); + GL11.glVertex2f(f, gx + i); + GL11.glTexCoord2f(j, kx); + GL11.glVertex2f(f + hx, gx + i); + GL11.glTexCoord2f(j, s); + GL11.glVertex2f(f + hx, gx); + GL11.glEnd(); + textureFilter.L(tx); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.resetColor(); + } + + public void L(float f, float g, float h, float i, int j) { + this.roundedOutline(f - hx, gx - hx, hx * 2.0F, hx * 2.0F, Float.MAX_VALUE, i, j); + } + + public void circle(float f, float g, float h, int i) { + this.roundedRect(f - hx, gx - hx, hx * 2.0F, hx * 2.0F, Float.MAX_VALUE, i); + } + + public void L(float f, float g, float h, float i, float j, float k, float l, float m, int n, int o, int p, int q) { + this.L(f, gx, hx, i, j, kx, l, mx, 0.0F, 0.0F, n, o, p, q); + } + + public void scaleAround(float f, float g, float h) { + GlStateManager.translate(gx, hx, 0.0F); + GlStateManager.scale(f, f, 1.0F); + GlStateManager.translate(-gx, -hx, 0.0F); + if (f > 0.0F) { + this.V /= f; + } + } + + public void L(float f, float g, float h, float i) { + if (!(hx <= 0.0F) && !(i <= 0.0F)) { + Hct hct = Hct.L(ThemeManager.getAccentColor()); + double dx = hct.D(); + double ex = hct.L() * 0.6; + int j = TonalPalette.L(dx - 25.0, ex).L(15); + int kx = TonalPalette.L(dx + 20.0, ex).L(27); + int l = TonalPalette.L(dx + 60.0, ex).L(41); + int mx = TonalPalette.L(dx - 45.0, ex).L(57); + ShaderProgram shaderProgramx; + if (!(shaderProgramx = D()).isLoaded()) { + this.L(f, gx, hx, i, 0.0F, kx, l, j, j); + } else { + GlStateManager.disableTexture2D(); + shaderProgramx.use(); + shaderProgramx.setUniform1f("uAspect", hx / i); + shaderProgramx.setUniform1f("uTime", (float)(System.nanoTime() - L) / 1.0E9F); + shaderProgramx.setUniformColor("uGlow", mx); + shaderProgramx.setUniformColor("uMid", kx); + shaderProgramx.setUniformColor("uAccent", l); + shaderProgramx.setUniformColor("uDeep", j); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glBegin(7); + GL11.glTexCoord2f(0.0F, 0.0F); + GL11.glVertex2f(f, gx); + GL11.glTexCoord2f(0.0F, 1.0F); + GL11.glVertex2f(f, gx + i); + GL11.glTexCoord2f(1.0F, 1.0F); + GL11.glVertex2f(f + hx, gx + i); + GL11.glTexCoord2f(1.0F, 0.0F); + GL11.glVertex2f(f + hx, gx); + GL11.glEnd(); + ShaderProgram.unbind(); + GlStateManager.resetColor(); + } + } + } + + public void L(ResourceLocation resourceLocation, float f, float g, float h, float i, int j, int k, int l, int m) { + mc.getTextureManager().bindTexture(resourceLocation); + GlStateManager.enableTexture2D(); + GlStateManager.enableBlend(); + GlStateManager.shadeModel(7425); + GlStateManager.disableCull(); + GlStateManager.disableAlpha(); + GlStateManager.depthMask(false); + GlStateManager.tryBlendFuncSeparate(770, 1, 0, 1); + int n = TextureFilter.MINIFIED.L(); + GL11.glBegin(7); + this.d(f, gx, 0.0F, 0.99F, j); + this.d(f, gx + i, 0.99F, 0.99F, kx); + this.d(f + hx, gx + i, 0.99F, 0.0F, l); + this.d(f + hx, gx, 0.0F, 0.0F, mx); + GL11.glEnd(); + TextureFilter.MINIFIED.L(n); + GlStateManager.depthMask(true); + GlStateManager.enableAlpha(); + GlStateManager.enableCull(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 771); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.resetColor(); + } + + public void roundedOutline(float f, float g, float h, float i, float j, float k, int l) { + this.L(f, gx, hx, i, j, j, j, j, -kx, 0.0F, l, l, l, l); + } + + public void L(float f, float g, float h, float i, float j, int k) { + Render2D render2D1 = this; + j *= (float) (Math.PI * 2); + + int l; + for (int n = l = 0; n < 24; n = l) { + float mx = j + 4.523894F * (l / 24.0F); + float o = f + (float)Math.cos(mx) * hx; + float p = gx + (float)Math.sin(mx) * hx; + l++; + render2D1.circle(o, p, i / 2.0F, kx); + } + } +} diff --git a/src/openonyx/render/RenderSupport_120.java b/src/openonyx/render/RenderSupport_120.java new file mode 100644 index 0000000..e626588 --- /dev/null +++ b/src/openonyx/render/RenderSupport_120.java @@ -0,0 +1,75 @@ +package openonyx.render; + +import openonyx.core.OnyxClient; + +public final class RenderSupport_120 { + public static boolean L() { + return BoxBlurShader.L() && OnyxClient.moduleManager != null && OnyxClient.moduleManager.clickGUI.frostedGlass.isEnabled(); + } + + public static void L(Render2D render2D, float f, float g, float h, float i, float j, int k, boolean bl) { + if (L(bl)) { + render2D.blurRect(f, g, h, i, j, k); + } else { + render2D.roundedRect(f, g, h, i, j, k); + } + } + + public static void L(Render2D render2D, float f, float g, float h, float i, float j, int k) { + L(render2D, f, g, h, i, j, k, true); + } + + public static void d() { + if (L()) { + BoxBlurShader.d(); + } + } + + public static boolean L(boolean bl) { + return bl && L(); + } + + private RenderSupport_120() { + } + + public static String decrypt(String string) { + String string1 = string; + int k = --4 << --4 ^ 10; + 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 = 119; + k = m; + byte b = 116; + + 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); + } + + public static void L(boolean bl) { + if (L(bl)) { + BoxBlurShader.D(); + } + } + + public static void L() { + L(true); + } +} diff --git a/src/openonyx/render/RenderSupport_133.java b/src/openonyx/render/RenderSupport_133.java new file mode 100644 index 0000000..2bf87d9 --- /dev/null +++ b/src/openonyx/render/RenderSupport_133.java @@ -0,0 +1,173 @@ +package openonyx.render; + +import java.nio.FloatBuffer; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.client.shader.Shader; +import net.minecraft.entity.Entity; +import net.minecraft.util.AxisAlignedBB; +import openonyx.features.render.GlowESP; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; + +public final class RenderSupport_133 { + private static int k = 1; + private static float g; + private static float M; + private static final float L = 1.0E-4F; + private static final double j = 0.5; + private static final float[] m; + private static final int[] h; + private static boolean l; + private static boolean I; + private static float d; + private static int i = 1; + private static float f; + private static final FloatBuffer FLOAT_BUFFER = BufferUtils.createFloatBuffer(16); + private static final FloatBuffer FLOAT_BUFFER2 = BufferUtils.createFloatBuffer(16); + + public static void d(float f, int i, int j) { + if (l) { + L(fx, ix, jx); + GL11.glEnable(3089); + GL11.glScissor(h[0], h[1], h[2], h[3]); + I = true; + } + } + + static { + float[] fx = new float[2]; + boolean bl = true; + m = fx; + int[] ix = new int[4]; + bl = true; + h = ix; + } + + private static void L(float f, int i, int j) { + float hx = (float)ix / k; + float gx = (float)jx / i; + int lx = Math.clamp((int)Math.floor((d - fx) * hx) - 1, 0, ix - 1); + int kx = Math.clamp((int)Math.floor((f - fx) * gx) - 1, 0, jx - 1); + ix = Math.clamp((int)Math.ceil((g + fx) * hx) + 1, lx + 1, ix); + jx = Math.clamp((int)Math.ceil((M + fx) * gx) + 1, kx + 1, jx); + h[0] = lx; + h[1] = kx; + h[2] = ix - lx; + h[3] = jx - kx; + } + + private static boolean L(float f, float g, float h) { + float ix = FLOAT_BUFFER2.get(0) * fx + FLOAT_BUFFER2.get(4) * gx + FLOAT_BUFFER2.get(8) * hx + FLOAT_BUFFER2.get(12); + float jx = FLOAT_BUFFER2.get(1) * fx + FLOAT_BUFFER2.get(5) * gx + FLOAT_BUFFER2.get(9) * hx + FLOAT_BUFFER2.get(13); + gx = FLOAT_BUFFER2.get(2) * fx + FLOAT_BUFFER2.get(6) * gx + FLOAT_BUFFER2.get(10) * hx + FLOAT_BUFFER2.get(14); + if (!((hx = FLOAT_BUFFER.get(3) * ix + FLOAT_BUFFER.get(7) * jx + FLOAT_BUFFER.get(11) * gx + FLOAT_BUFFER.get(15)) > 1.0E-4F)) { + return false; + } + + float kx = FLOAT_BUFFER.get(0) * ix + FLOAT_BUFFER.get(4) * jx + FLOAT_BUFFER.get(8) * gx + FLOAT_BUFFER.get(12); + gx = FLOAT_BUFFER.get(1) * ix + FLOAT_BUFFER.get(5) * jx + FLOAT_BUFFER.get(9) * gx + FLOAT_BUFFER.get(13); + m[0] = (kx / hx * 0.5F + 0.5F) * k; + m[1] = (gx / hx * 0.5F + 0.5F) * i; + return Float.isFinite(m[0]) && Float.isFinite(m[1]); + } + + public static void L(List list, float f, double d, double e, double g) { + List list1 = list; + l = false; + if (GlowESP.I() && !list1.isEmpty()) { + Minecraft minecraft = Minecraft.getMinecraft(); + k = Math.max(1, minecraft.displayWidth); + i = Math.max(1, minecraft.displayHeight); + FLOAT_BUFFER2.clear(); + FLOAT_BUFFER.clear(); + GL11.glGetFloat(2982, FLOAT_BUFFER2); + GL11.glGetFloat(2983, FLOAT_BUFFER); + float s = Float.MAX_VALUE; + float hx = Float.MAX_VALUE; + float ix = -Float.MAX_VALUE; + float jx = -Float.MAX_VALUE; + int kx = 0; + + for (int bb = kx; bb < list1.size(); bb = ++kx) { + Entity entity; + Entity entity1 = entity = (Entity)list1.get(kx); + AxisAlignedBB axisAlignedBB = entity1.getEntityBoundingBox(); + double lx = entity1.lastTickPosX + (entity.posX - entity.lastTickPosX) * fx - entity.posX - dx; + double n = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * fx - entity.posY - e; + double p = entity1.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * fx - entity.posZ - gx; + float r = (float)(axisAlignedBB.minX + lx - 0.5); + float t = (float)(axisAlignedBB.minY + n - 0.5); + float q = (float)(axisAlignedBB.minZ + p - 0.5); + float u = (float)(axisAlignedBB.maxX + lx + 0.5); + float mx = (float)(axisAlignedBB.maxY + n + 0.5); + float v = (float)(axisAlignedBB.maxZ + p + 0.5); + + int o; + for (int w = o = 0; w < 8; w = o) { + float x; + int y; + if ((o & 1) == 0) { + x = r; + y = o; + } else { + x = u; + y = o; + } + + float z; + int ba; + if ((y & 2) == 0) { + z = t; + ba = o; + } else { + z = mx; + ba = o; + } + + if (!L(x, z, (ba & 4) == 0 ? q : v)) { + return; + } + + s = Math.min(s, m[0]); + hx = Math.min(hx, m[1]); + ix = Math.max(ix, m[0]); + o++; + jx = Math.max(jx, m[1]); + } + } + + d = s; + f = hx; + g = ix; + M = jx; + l = true; + } + } + + public static boolean L() { + return l; + } + + public static void L(Shader shader, float f) { + Shader shader1 = shader; + if (!l) { + shader1.clearScissor(); + } else { + Framebuffer framebuffer = shader1.framebufferOut; + L(fx, framebuffer.framebufferTextureWidth, framebuffer.framebufferTextureHeight); + shader1.setScissor(h[0], h[1], h[2], h[3]); + } + } + + public static void L() { + if (I) { + GL11.glDisable(3089); + I = false; + } + } + + private RenderSupport_133() { + } +}