diff --git a/src/openonyx/render/ChamsShader.java b/src/openonyx/render/ChamsShader.java new file mode 100644 index 0000000..bb13914 --- /dev/null +++ b/src/openonyx/render/ChamsShader.java @@ -0,0 +1,148 @@ +package openonyx.render; + +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import openonyx.core.MinecraftAccess; +import openonyx.core.OnyxClient; +import openonyx.events.TargetType; +import openonyx.features.render.Chams; +import openonyx.features.render.ChamsPart; +import openonyx.render.group_p.ShaderProgram; +import openonyx.theme.internal.ColorUtils; +import org.lwjgl.opengl.GL11; + +public final class ChamsShader implements MinecraftAccess { + private static float j; + private static boolean m = true; + private static boolean h; + private static boolean l; + private static ShaderProgram shaderProgram; + private static float d; + private static float i; + private static boolean f; + private static float H; + private static float e; + + public static void d() { + if (h) { + h = false; + ShaderProgram.unbind(); + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + GlStateManager.disableBlend(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.resetColor(); + } + } + + public static boolean d() { + if (h && f) { + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + shaderProgram.setUniform4f("uTint", i, e, j, d); + return true; + } else { + return false; + } + } + + public static boolean L(Entity entity) { + if (entity instanceof EntityLivingBase entityLivingBase) { + if (!L()) { + return false; + } + + Chams chams = OnyxClient.moduleManager.chams; + TargetType targetType; + return (targetType = OnyxClient.moduleManager.chams.L(entityLivingBase)) != null && chams.L(targetType); + } else { + return false; + } + } + + public static boolean L(EntityLivingBase entityLivingBase) { + EntityLivingBase entityLivingBase1 = entityLivingBase; + if (!m || OnyxClient.moduleManager == null) { + return false; + } + + if (!OpenGlHelper.shadersSupported) { + return false; + } + + Chams chams = OnyxClient.moduleManager.chams; + TargetType targetType; + if ((targetType = OnyxClient.moduleManager.chams.L(entityLivingBase1)) == null) { + return false; + } + + if (!l) { + l = true; + shaderProgram = ShaderProgram.load("onyx_chams"); + } + + if (shaderProgram != null && shaderProgram.isLoaded()) { + ChamsPart chamsPart = chams.L(targetType); + int ix; + i = ColorUtils.red(ix = chams.L(targetType)) / 255.0F; + e = ColorUtils.green(ix) / 255.0F; + j = ColorUtils.blue(ix) / 255.0F; + H = ColorUtils.alpha(ix) / 255.0F; + f = chams.L(targetType); + d = H * chams.L(targetType); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 771); + GlStateManager.depthMask(true); + shaderProgram.use(); + shaderProgram.setUniform1i("Sampler0", 0); + shaderProgram.setUniform1i("Sampler1", 1); + shaderProgram.setUniform4f("uTint", i, e, j, H); + shaderProgram.setUniform4f("uStyle", chamsPart.strength.getFloat() / 100.0F, 0.0F, 0.0F, chams.d(targetType)); + shaderProgram.setUniform1f("uFogEnabled", GL11.glIsEnabled(2912) ? 1.0F : 0.0F); + h = true; + return true; + } else { + m = false; + return false; + } + } + + public static void L() { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + shaderProgram.setUniform4f("uTint", i, e, j, H); + } + + private ChamsShader() { + } + + public static boolean L() { + if (m && OnyxClient.moduleManager != null) { + if (!OpenGlHelper.shadersSupported) { + return false; + } + + Chams chams = OnyxClient.moduleManager.chams; + if (!OnyxClient.moduleManager.chams.isEnabled()) { + return false; + } + + TargetType[] targetTypes; + int ix = (targetTypes = TargetType.values()).length; + + int jx; + for (int k = jx = 0; k < ix; k = ++jx) { + TargetType targetType = targetTypes[jx]; + if (chams.L(targetType).isEnabled() && chams.L(targetType)) { + return true; + } + } + + return false; + } else { + return false; + } + } +} diff --git a/src/openonyx/render/CustomCursor.java b/src/openonyx/render/CustomCursor.java new file mode 100644 index 0000000..e4adbab --- /dev/null +++ b/src/openonyx/render/CustomCursor.java @@ -0,0 +1,157 @@ +package openonyx.render; + +import java.nio.IntBuffer; +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Cursor; +import org.lwjgl.input.Mouse; + +public final class CustomCursor { + private static final int M = -1; + private static boolean L; + private static final int j = 16; + private static final int m = 0; + private static Cursor cursor; + private static Cursor cursor2; + private static boolean I; + private static final int d = -16777216; + private static final String[] i; + private static final String[] f; + private static CustomCursorMode customCursorMode = CustomCursorMode.DEFAULT; + private static CustomCursorMode customCursorMode2 = CustomCursorMode.DEFAULT; + + private static void D() { + if (!I) { + I = true; + if ((Cursor.getCapabilities() & 1) != 0 && Cursor.getMinCursorSize() <= 16 && Cursor.getMaxCursorSize() >= 16) { + cursor = L(i, 5, 0); + cursor2 = L(f, 5, 7); + if (cursor == null || cursor2 == null) { + L = true; + } + } else { + L = true; + } + } + } + + private CustomCursor() { + } + + public static void d() { + customCursorMode2 = CustomCursorMode.DEFAULT; + if (!L && customCursorMode != CustomCursorMode.DEFAULT) { + try { + Mouse.setNativeCursor(null); + } catch (LWJGLException | RuntimeException lWJGLException) { + } + + customCursorMode = CustomCursorMode.DEFAULT; + } + } + + public static void L(CustomCursorMode customCursorMode) { + if (customCursorModex.ordinal() > customCursorMode2.ordinal()) { + customCursorMode2 = customCursorModex; + } + } + + static { + String[] strings = new String[16]; + boolean bl = true; + strings[0] = " ## "; + strings[1] = " #..# "; + strings[2] = " #..# "; + strings[3] = " #..# "; + strings[4] = " #..# "; + strings[5] = " #..# ## "; + strings[6] = " #..##..# "; + strings[7] = " #..#..#.# "; + strings[8] = " ## #..#..#..# "; + strings[9] = "#..##........# "; + strings[10] = "#............# "; + strings[11] = " #...........# "; + strings[12] = " #..........# "; + strings[13] = " #.........# "; + strings[14] = " #........# "; + strings[15] = " ######### "; + i = strings; + strings = new String[16]; + bl = true; + strings[0] = " "; + strings[1] = " ## ## "; + strings[2] = " #.##.# "; + strings[3] = " #..# "; + strings[4] = " #..# "; + strings[5] = " #..# "; + strings[6] = " #..# "; + strings[7] = " #..# "; + strings[8] = " #..# "; + strings[9] = " #..# "; + strings[10] = " #..# "; + strings[11] = " #..# "; + strings[12] = " #..# "; + strings[13] = " #.##.# "; + strings[14] = " ## ## "; + strings[15] = " "; + f = strings; + } + + public static void L() { + CustomCursorMode customCursorModex = customCursorMode2; + customCursorMode2 = CustomCursorMode.DEFAULT; + if (!L && customCursorModex != customCursorMode) { + D(); + if (!L) { + Cursor cursorx = switch (customCursorModex) { + case DEFAULT -> { + yield null; + + while (false) { + } + } + case TEXT -> cursor; + case POINTER -> cursor2; + }; + + try { + Mouse.setNativeCursor(cursorx); + customCursorMode = customCursorModex; + } catch (LWJGLException | RuntimeException lWJGLException) { + L = true; + } + } + } + } + + private static Cursor L(String[] strings, int i, int j) { + String[] strings1 = strings; + IntBuffer intBuffer = BufferUtils.createIntBuffer(256); + + for (int n = l = 15; n >= 0; n = --l) { + String string = strings1[l]; + + int k; + for (int mx = k = 0; mx < 16; mx = ++k) { + intBuffer.put(switch (string.charAt(k)) { + case '#' -> { + yield -16777216; + + while (false) { + } + } + case '.' -> -1; + default -> 0; + }); + } + } + + intBuffer.flip(); + + try { + return new Cursor(16, 16, ix, 15 - jx, 1, intBuffer, null); + } catch (LWJGLException | RuntimeException lWJGLException) { + return null; + } + } +} diff --git a/src/openonyx/render/CustomCursorMode.java b/src/openonyx/render/CustomCursorMode.java new file mode 100644 index 0000000..0d3fe2c --- /dev/null +++ b/src/openonyx/render/CustomCursorMode.java @@ -0,0 +1,16 @@ +package openonyx.render; + +public enum CustomCursorMode { + DEFAULT, + TEXT, + POINTER; + + private static CustomCursorMode[] L() { + CustomCursorMode[] customCursorModes = new CustomCursorMode[3]; + boolean bl = true; + customCursorModes[0] = DEFAULT; + customCursorModes[1] = POINTER; + customCursorModes[2] = TEXT; + return customCursorModes; + } +} diff --git a/src/openonyx/render/EntityProjection.java b/src/openonyx/render/EntityProjection.java new file mode 100644 index 0000000..fe0ac00 --- /dev/null +++ b/src/openonyx/render/EntityProjection.java @@ -0,0 +1,131 @@ +package openonyx.render; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.Vec3; + +public final class EntityProjection { + private static final double M = 0.05; + private static final double L = 8.0; + private static final double j = 24.0; + private static final double m = 0.05859375; + private static final float h = 1.0F; + private static final int l = 1; + private static final double I = 1.0; + private static final double d = 4.0; + private static final double i = -8.5; + private static final int f = 3; + private static final int H = 4; + private static final double e = 0.1875; + + private static float L(Entity entityLivingBase, float f) { + Entity entity = entityLivingBase; + return entity instanceof EntityLivingBase + ? (entityLivingBase = (EntityLivingBase)entity).prevRenderYawOffset + (entityLivingBase.renderYawOffset - entityLivingBase.prevRenderYawOffset) * fx + : entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * fx; + } + + public static String decrypt(String string) { + String string1 = string; + int k = (1 ^ 3 ^ 5) << 4 ^ 7; + String string2; + int n = (string2 = string1).length(); + char[] ex = new char[n]; + boolean bl = true; + int ix; + int mx = ix = n - 1; + char[] c = ex; + byte dx = 100; + k = mx; + byte b = 92; + + while (k >= 0) { + int lx = ix; + int jx = string2.charAt(ix); + ix--; + c[lx] = (char)(jx ^ b); + if (ix < 0) { + break; + } + + jx = ix--; + c[jx] = (char)(string2.charAt(jx) ^ dx); + k = ix; + } + + return new String(c); + } + + public static EntityProjectionData2 L(Entity entity, float f, float g, float h) { + Entity entity1 = entity; + if (!WorldToScreen.L()) { + return null; + } + + Vec3 vec3; + if ((vec3 = L(entity1, fx)).addVector(0.0, entity1.height * 0.5, 0.0).subtract(WorldToScreen.getVec3()).dotProduct(WorldToScreen.getVec32()) <= 0.05) { + return null; + } + + EntityProjectionData entityProjectionData = EntityProjectionData.L(entity1); + double dx; + double ex = Math.cos(dx = Math.toRadians(L(entity1, fx))) * entityProjectionData.halfWidth(); + double ix = Math.sin(dx) * entityProjectionData.halfWidth(); + double jx = -Math.sin(dx) * entityProjectionData.halfDepth(); + dx = Math.cos(dx) * entityProjectionData.halfDepth(); + fx = Float.MAX_VALUE; + float k = -Float.MAX_VALUE; + float lx = Float.MAX_VALUE; + float mx = -Float.MAX_VALUE; + + for (int t = q = 0; t < 8; t = q) { + double n = (q & 1) == 0 ? 1.0 : -1.0; + double o = (q & 2) == 0 ? 1.0 : -1.0; + double u = ex * n + jx * o; + double v; + double w; + if ((q & 4) == 0) { + v = entityProjectionData.top(); + w = ix; + } else { + v = entityProjectionData.bottom(); + w = ix; + } + + Vec3 vec31; + if ((vec31 = vec3.addVector(u, v, w * n + dx * o)).subtract(WorldToScreen.getVec3()).dotProduct(WorldToScreen.getVec32()) <= 0.05) { + return null; + } + + float[] p; + if ((p = WorldToScreen.L(vec31, g, hx)) == null) { + return null; + } + + fx = Math.min(fx, p[0]); + k = Math.max(k, p[0]); + lx = Math.min(lx, p[1]); + q++; + mx = Math.max(mx, p[1]); + } + + if (mx - lx <= 1.0F) { + return null; + } + + float[] r = WorldToScreen.L(vec3.addVector(0.0, entityProjectionData.top(), 0.0), g, hx); + float[] s = WorldToScreen.L(vec3.addVector(0.0, entityProjectionData.bottom(), 0.0), g, hx); + return r != null && s != null ? new EntityProjectionData2(fx, lx, k - fx, mx - lx, r[0], s[0]) : null; + } + + private static Vec3 L(Entity entity, float f) { + return new Vec3( + entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * fx, + entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * fx, + entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * fx + ); + } + + private EntityProjection() { + } +} diff --git a/src/openonyx/render/EntityProjectionData.java b/src/openonyx/render/EntityProjectionData.java new file mode 100644 index 0000000..8d5654d --- /dev/null +++ b/src/openonyx/render/EntityProjectionData.java @@ -0,0 +1,35 @@ +package openonyx.render; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; + +record EntityProjectionData(double halfWidth, double halfDepth, double top, double bottom) { + static EntityProjectionData L(Entity entity) { + Entity entity1 = entity; + if (entity1 instanceof EntityPlayer entityPlayer) { + double d = (32.5 - L(entityPlayer, 4)) * 0.05859375; + EntityProjectionData entityProjectionData = new EntityProjectionData; + double e = (8.0 + L(entityPlayer, 3)) * 0.05859375; + double f = (4.0 + L(entityPlayer, 4)) * 0.05859375; + double g; + EntityPlayer entityPlayer1; + if (entityPlayer.isSneaking()) { + g = d - 0.1875; + entityPlayer1 = entityPlayer; + } else { + g = d; + entityPlayer1 = entityPlayer; + } + + entityProjectionData./* $VF: Unable to resugar constructor */(e, f, g, -L(entityPlayer1, 1) * 0.05859375); + return entityProjectionData; + } else { + return new EntityProjectionData(entity1.width * 0.5, entity1.width * 0.5, entity1.height, 0.0); + } + } + + private static double L(EntityLivingBase entityLivingBase, int i) { + return entityLivingBase.getEquipmentInSlot(i) != null ? 1.0 : 0.0; + } +}