Upload files to "src/openonyx/render"

This commit is contained in:
winterflyt committed 2026-11-30 06:13:19 +02:00
1 parent f02aae37d5
commit c5a79852bc
5 files changed
+806

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
package openonyx.render;
import openonyx.core.MinecraftAccess;
import openonyx.core.OnyxClient;
import openonyx.features.render.Ambience;
import openonyx.render.group_p.ShaderProgram;
import openonyx.theme.internal.ColorUtils;
public final class AmbienceShader implements MinecraftAccess {
private static ShaderProgram shaderProgram;
private static boolean H;
private static final long e = System.nanoTime();
private AmbienceShader() {
}
public static void L() {
if (OnyxClient.moduleManager != null) {
Ambience ambience = OnyxClient.moduleManager.ambience;
if (OnyxClient.moduleManager.ambience.I() && PostProcessor.L()) {
if (!H) {
H = true;
shaderProgram = ShaderProgram.load("onyx_ambience");
}
if (shaderProgram != null && shaderProgram.isLoaded()) {
boolean bl = ambience.ambiencePart2.isEnabled();
boolean bl1 = ambience.ambiencePart.isEnabled();
int i = bl ? ambience.ambiencePart2.color.getOpaque() : -1;
float k = bl ? ambience.ambiencePart2.strength.getFloat() / 100.0F : 0.0F;
float f = bl1 ? ambience.ambiencePart.saturation.getFloat() / 100.0F : 1.0F;
float g = bl1 ? ambience.ambiencePart.contrast.getFloat() / 100.0F : 1.0F;
float h = bl1 ? ambience.ambiencePart.vignette.getFloat() / 100.0F : 0.0F;
float l = bl1 ? ambience.ambiencePart.filmGrain.getFloat() / 100.0F : 0.0F;
float j = (float)(System.nanoTime() - e) / 1.0E9F;
PostProcessor.L(
shaderProgram,
shaderProgram -> {
shaderProgramx.setUniform4f(
"uLightColorAndStrength", ColorUtils.red(i) / 255.0F, ColorUtils.green(i) / 255.0F, ColorUtils.blue(i) / 255.0F, k
);
shaderProgramx.setUniform4f("uGradeParams", f, g, h, l);
shaderProgramx.setUniform1f("uTime", j);
}
);
}
}
}
}
}
+93
View File
@@ -0,0 +1,93 @@
package openonyx.render;
import net.minecraft.client.renderer.GlStateManager;
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.theme.internal.ColorUtils;
public final class BedBoxRenderer implements MinecraftAccess {
private static Vec3 vec3 = new Vec3(0.0, 0.0, 0.0);
private static boolean e;
private static void L(WorldRenderer worldRenderer, double d, double e, double f, int i) {
worldRenderer.pos(d, ex, f).color(ColorUtils.red(i), ColorUtils.green(i), ColorUtils.blue(i), ColorUtils.alpha(i)).endVertex();
}
public static void L() {
if (e) {
e = false;
GlStateManager.shadeModel(7424);
GlStateManager.depthMask(true);
GlStateManager.enableDepth();
GlStateManager.enableCull();
GlStateManager.disableBlend();
GlStateManager.enableLighting();
GlStateManager.enableTexture2D();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
}
private BedBoxRenderer() {
}
private static void L(WorldRenderer worldRenderer, double d, double e, double f, double g, double h, double i, int j, int k) {
L(worldRenderer, d, h, ex, j);
L(worldRenderer, f, h, g, j);
L(worldRenderer, f, i, g, k);
L(worldRenderer, d, i, ex, k);
}
public static boolean L(float f, boolean bl) {
float g = f;
Entity entity;
if ((entity = mc.getRenderViewEntity()) == null) {
return false;
}
vec3 = new Vec3(
entity.prevPosX + (entity.posX - entity.prevPosX) * g,
entity.prevPosY + (entity.posY - entity.prevPosY) * g,
entity.prevPosZ + (entity.posZ - entity.prevPosZ) * g
);
GlStateManager.pushMatrix();
GlStateManager.disableTexture2D();
GlStateManager.disableLighting();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.disableCull();
GlStateManager.shadeModel(7425);
GlStateManager.depthMask(false);
if (bl) {
GlStateManager.disableDepth();
}
e = true;
return true;
}
public static void L(double d, double e, double f, double g, double h, int i, int j) {
int n = i;
if (e) {
h /= 2.0;
double k = d - h - vec3.xCoord;
double l = d + h - vec3.xCoord;
double m = ex - h - vec3.zCoord;
ex = ex + h - vec3.zCoord;
f -= vec3.yCoord;
g -= vec3.yCoord;
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRenderer = tessellator.getWorldRenderer();
worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
L(worldRenderer, k, m, l, m, f, g, n, j);
L(worldRenderer, l, m, l, ex, f, g, n, j);
L(worldRenderer, l, ex, k, ex, f, g, n, j);
L(worldRenderer, k, ex, k, m, f, g, n, j);
tessellator.draw();
}
}
}
+358
View File
@@ -0,0 +1,358 @@
package openonyx.render;
import java.nio.ByteBuffer;
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.OnyxClient;
import openonyx.render.group_p.ShaderProgram;
import org.lwjgl.opengl.GL11;
public final class BoxBlurShader {
private static final int E = 5888;
private static final int F = 32;
private static final float G = 8.0F;
private static int A = -1;
private static boolean K;
private static boolean B;
private static int C;
private static int J;
private static int D;
private static final int c = 64;
private static ShaderProgram shaderProgram;
private static int k;
private static int g;
private static int M;
private static final int L = 5889;
private static int j;
private static int m = -1;
private static int h = -1;
private static boolean l = true;
private static int I = -1;
private static boolean d;
private static int i;
private static boolean f;
private static int H = -1;
private static final int e = 2;
public static void l() {
if (B && L()) {
B = false;
try {
Minecraft minecraft;
Framebuffer framebuffer = (minecraft = Minecraft.getMinecraft()).getFramebuffer();
boolean bl = OpenGlHelper.isFramebufferEnabled() && framebuffer != null;
int ix = bl ? framebuffer.framebufferWidth : minecraft.displayWidth;
int jx = bl ? framebuffer.framebufferHeight : minecraft.displayHeight;
if (ix <= 0 || jx <= 0) {
return;
}
if (shaderProgram == null) {
shaderProgram = ShaderProgram.load("box_blur");
}
if (shaderProgram.isLoaded()) {
int kx = Math.max(1, ix / 2);
int lx = Math.max(1, jx / 2);
L(kx, lx);
int mx = bl ? framebuffer.framebufferTexture : d(ix, jx);
d(kx, lx);
L(kx, lx, ix, jx);
GlStateManager.bindTexture(mx);
GL11.glTexParameteri(3553, 10241, 9729);
GL11.glTexParameteri(3553, 10240, 9729);
L(mx, I, kx, lx, 0.0F, 0.0F);
L(m, H, kx, lx, 1.0F, 0.0F);
L(A, I, kx, lx, 0.0F, 1.0F);
L(m, H, kx, lx, 1.0F, 0.0F);
L(A, I, kx, lx, 0.0F, 1.0F);
if (bl) {
GlStateManager.bindTexture(mx);
GL11.glTexParameteri(3553, 10241, 9728);
GL11.glTexParameteri(3553, 10240, 9728);
}
I();
L(minecraft, framebuffer, bl, ix, jx);
return;
}
L(null);
} catch (Throwable throwable) {
L(throwable);
L();
return;
} finally {
i();
}
}
}
private static void h() {
if (I != -1) {
OpenGlHelper.glDeleteFramebuffers(I);
I = -1;
}
if (H != -1) {
OpenGlHelper.glDeleteFramebuffers(H);
H = -1;
}
if (m != -1) {
TextureUtil.deleteTexture(m);
m = -1;
}
if (A != -1) {
TextureUtil.deleteTexture(A);
A = -1;
}
if (h != -1) {
TextureUtil.deleteTexture(h);
h = -1;
}
M = 0;
k = 0;
J = 0;
j = 0;
}
private static int d(int i, int j) {
OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, 0);
if (h != -1 && J == ix && j == jx) {
GlStateManager.bindTexture(h);
} else {
if (h == -1) {
h = TextureUtil.glGenTextures();
}
GlStateManager.bindTexture(h);
D(ix, jx);
J = ix;
j = jx;
}
GL11.glCopyTexSubImage2D(3553, 0, 0, 0, 0, 0, ix, jx);
return h;
}
private static int L(int i) {
int jx = ix;
if ((ix = OpenGlHelper.glGenFramebuffers()) == -1) {
return -1;
}
OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, ix);
OpenGlHelper.glFramebufferTexture2D(OpenGlHelper.GL_FRAMEBUFFER, OpenGlHelper.GL_COLOR_ATTACHMENT0, 3553, jx, 0);
int kx = OpenGlHelper.glCheckFramebufferStatus(OpenGlHelper.GL_FRAMEBUFFER);
OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, 0);
return kx == OpenGlHelper.GL_FRAMEBUFFER_COMPLETE ? ix : -1;
}
private BoxBlurShader() {
}
private static int L(int i, int j) {
int kx = ix;
GlStateManager.bindTexture(ix = TextureUtil.glGenTextures());
D(kx, jx);
return ix;
}
private static void L(Minecraft minecraft, Framebuffer framebuffer, boolean bl, int i, int j) {
OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, 0);
if (bl) {
framebuffer.bindFramebuffer(true);
} else {
GlStateManager.viewport(0, 0, ix, jx);
}
}
private static void I() {
ShaderProgram.unbind();
GlStateManager.matrixMode(5889);
GlStateManager.popMatrix();
GlStateManager.matrixMode(5888);
GlStateManager.popMatrix();
GlStateManager.enableDepth();
GlStateManager.enableAlpha();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.resetColor();
}
private static void D(int i, int j) {
GL11.glTexImage2D(3553, 0, 32856, ix, jx, 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);
}
private static void i() {
if (f) {
f = false;
GL11.glDisable(3089);
}
}
public static void D() {
if (L()) {
B = true;
}
}
public static void d(int i, int j, int k, int l) {
if (kx > 0 && lx > 0) {
if (d) {
D = Math.min(D, ix);
i = Math.min(i, jx);
C = Math.max(C, ix + kx);
g = Math.max(g, jx + lx);
} else {
D = ix;
i = jx;
C = ix + kx;
g = jx + lx;
d = true;
}
}
}
private static void L(int i) {
OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, ix);
GlStateManager.clearColor(0.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.clear(16384);
OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, 0);
}
private static void L(Throwable throwable) {
l = false;
try {
h();
} catch (Throwable throwable1) {
}
OnyxClient.LOGGER.warn("Frosted glass unavailable, falling back to an opaque panel", throwable);
}
private static void L(int i, int j, int k, int l, float f, float g) {
OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, jx);
GlStateManager.bindTexture(ix);
shaderProgram.use();
shaderProgram.setUniform1i("Sampler0", 0);
shaderProgram.setUniform2f("uResolution", kx, lx);
shaderProgram.setUniform2f("uBlurDir", fx, gx);
shaderProgram.setUniform1f("uRadius", fx == 0.0F && gx == 0.0F ? 0.0F : 8.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glBegin(7);
GL11.glTexCoord2f(0.0F, 0.0F);
GL11.glVertex2f(0.0F, 0.0F);
GL11.glTexCoord2f(1.0F, 0.0F);
GL11.glVertex2f(1.0F, 0.0F);
GL11.glTexCoord2f(1.0F, 1.0F);
GL11.glVertex2f(1.0F, 1.0F);
GL11.glTexCoord2f(0.0F, 1.0F);
GL11.glVertex2f(0.0F, 1.0F);
GL11.glEnd();
}
public static boolean L() {
return l && OpenGlHelper.framebufferSupported;
}
private static void d(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.enableTexture2D();
GlStateManager.viewport(0, 0, ix, jx);
}
public static void d() {
if (L()) {
B = true;
K = true;
}
}
public static int L() {
return L() ? m : -1;
}
private static void L() {
try {
Minecraft minecraft;
Minecraft minecraft1 = minecraft = Minecraft.getMinecraft();
Framebuffer framebuffer = minecraft1.getFramebuffer();
boolean bl;
Minecraft minecraft2;
if (OpenGlHelper.isFramebufferEnabled() && minecraft.getFramebuffer() != null) {
bl = true;
minecraft2 = minecraft;
} else {
bl = false;
minecraft2 = minecraft;
}
L(minecraft1, framebuffer, bl, minecraft2.displayWidth, minecraft.displayHeight);
} catch (Throwable throwable) {
}
}
private static void L(int i, int j, int k, int l) {
int mx = d && !K;
int n = D;
int o = i;
int p = C;
int q = g;
d = false;
K = false;
if (mx) {
float fx = (float)ix / kx;
float gx = (float)jx / lx;
mx = 32 + Math.round(64.0F * Math.max(fx, gx));
n = Math.clamp((int)Math.floor(n * fx) - mx, 0, ix);
o = Math.clamp((int)Math.floor(o * gx) - mx, 0, jx);
kx = Math.clamp((int)Math.ceil(p * fx) + mx, n, ix);
jx = Math.clamp((int)Math.ceil(q * gx) + mx, o, jx);
if (kx > n && jx > o) {
GL11.glEnable(3089);
GL11.glScissor(n, o, kx - n, jx - o);
f = true;
}
}
}
private static void L(int i, int j) {
if (I == -1 || M != ix || k != jx) {
h();
m = L(ix, jx);
A = L(ix, jx);
I = L(m);
H = L(A);
if (I != -1 && H != -1) {
M = ix;
k = jx;
L(I);
L(H);
} else {
throw new IllegalStateException("could not create blur render targets");
}
}
}
}
+227
View File
@@ -0,0 +1,227 @@
package openonyx.render;
import net.minecraft.client.renderer.GlStateManager;
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.AxisAlignedBB;
import net.minecraft.util.Vec3;
import openonyx.core.MinecraftAccess;
import openonyx.theme.internal.ColorUtils;
import org.lwjgl.opengl.GL11;
public final class BoxRenderer implements MinecraftAccess {
private static boolean f;
private static final int[][] H;
private static Vec3 vec3 = new Vec3(0.0, 0.0, 0.0);
public static void L(AxisAlignedBB axisAlignedBB, int i, float f, int j) {
if (f) {
double d = axisAlignedBB.minX - vec3.xCoord;
double e = axisAlignedBB.minY - vec3.yCoord;
double g = axisAlignedBB.minZ - vec3.zCoord;
double h = axisAlignedBB.maxX - vec3.xCoord;
double l = axisAlignedBB.maxY - vec3.yCoord;
double m = axisAlignedBB.maxZ - vec3.zCoord;
double[][] u = new double[8][];
int v = 1;
double[] r = new double[3];
boolean bl = true;
r[0] = d;
r[1] = e;
r[2] = g;
u[0] = r;
double[] s = new double[3];
bl = true;
s[0] = h;
s[1] = e;
s[2] = g;
u[1] = s;
double[] t = new double[3];
bl = true;
t[0] = d;
t[1] = e;
t[2] = m;
u[2] = t;
double[] w = new double[3];
boolean bl1 = true;
w[0] = h;
w[1] = e;
w[2] = m;
u[3] = w;
w = new double[3];
bl1 = true;
w[0] = d;
w[1] = l;
w[2] = g;
u[4] = w;
w = new double[3];
bl1 = true;
w[0] = h;
w[1] = l;
w[2] = g;
u[5] = w;
w = new double[3];
bl1 = true;
w[0] = d;
w[1] = l;
w[2] = m;
u[6] = w;
w = new double[3];
bl1 = true;
w[0] = h;
w[1] = l;
w[2] = m;
u[7] = w;
double[][] o = u;
Tessellator tessellator;
WorldRenderer worldRenderer = (tessellator = Tessellator.getInstance()).getWorldRenderer();
if (ColorUtils.alpha(j) > 0) {
worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
L(worldRenderer, o, j, 0, 1, 3, 2);
L(worldRenderer, o, j, 4, 5, 7, 6);
L(worldRenderer, o, j, 0, 1, 5, 4);
L(worldRenderer, o, j, 2, 3, 7, 6);
L(worldRenderer, o, j, 0, 2, 6, 4);
L(worldRenderer, o, j, 1, 3, 7, 5);
tessellator.draw();
}
if (ColorUtils.alpha(i) > 0) {
GL11.glLineWidth(fx);
worldRenderer.begin(1, DefaultVertexFormats.POSITION_COLOR);
int[][] n = H;
j = H.length;
int k;
for (int q = k = 0; q < j; q = k) {
int[] p = n[k];
L(worldRenderer, o[p[0]], i);
v = p[1];
k++;
L(worldRenderer, o[v], i);
}
tessellator.draw();
}
}
}
static {
int[][] j = new int[12][];
boolean bl = true;
int[] i = new int[2];
boolean bl1 = true;
i[0] = 0;
i[1] = 1;
j[0] = i;
j[1] = new int[]{1, 3};
int[] k = new int[2];
boolean bl2 = true;
k[0] = 3;
k[1] = 2;
j[2] = k;
k = new int[2];
bl2 = true;
k[0] = 2;
k[1] = 0;
j[3] = k;
k = new int[2];
bl2 = true;
k[0] = 4;
k[1] = 5;
j[4] = k;
k = new int[2];
bl2 = true;
k[0] = 5;
k[1] = 7;
j[5] = k;
k = new int[2];
bl2 = true;
k[0] = 7;
k[1] = 6;
j[6] = k;
k = new int[2];
bl2 = true;
k[0] = 6;
k[1] = 4;
j[7] = k;
k = new int[2];
bl2 = true;
k[0] = 0;
k[1] = 4;
j[8] = k;
j[9] = new int[]{1, 5};
k = new int[2];
bl2 = true;
k[0] = 2;
k[1] = 6;
j[10] = k;
k = new int[2];
bl2 = true;
k[0] = 3;
k[1] = 7;
j[11] = k;
H = j;
}
private BoxRenderer() {
}
public static boolean L(float f, boolean bl) {
float g = fx;
Entity entity;
if ((entity = mc.getRenderViewEntity()) == null) {
return false;
}
vec3 = new Vec3(
entity.prevPosX + (entity.posX - entity.prevPosX) * g,
entity.prevPosY + (entity.posY - entity.prevPosY) * g,
entity.prevPosZ + (entity.posZ - entity.prevPosZ) * g
);
GlStateManager.pushMatrix();
GlStateManager.disableTexture2D();
GlStateManager.disableLighting();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.disableCull();
GlStateManager.depthMask(false);
if (bl) {
GlStateManager.disableDepth();
}
GL11.glEnable(2848);
GL11.glHint(3154, 4354);
f = true;
return true;
}
private static void L(WorldRenderer worldRenderer, double[][] d, int i, int j, int k, int l, int m) {
L(worldRenderer, d[j], i);
L(worldRenderer, d[k], i);
L(worldRenderer, d[l], i);
L(worldRenderer, d[m], i);
}
public static void L() {
if (f) {
f = false;
GL11.glDisable(2848);
GL11.glLineWidth(1.0F);
GlStateManager.depthMask(true);
GlStateManager.enableDepth();
GlStateManager.enableCull();
GlStateManager.disableBlend();
GlStateManager.enableLighting();
GlStateManager.enableTexture2D();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
}
private static void L(WorldRenderer worldRenderer, double[] d, int i) {
worldRenderer.pos(d[0], d[1], d[2]).color(ColorUtils.red(i), ColorUtils.green(i), ColorUtils.blue(i), ColorUtils.alpha(i)).endVertex();
}
}
+78
View File
@@ -0,0 +1,78 @@
package openonyx.render;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
public final class CameraState {
private static float M;
private static float L;
private static float j;
private static boolean m;
private static float h;
private static float l;
private static float I;
private static float d;
private static float i;
private static float f;
private static boolean H;
private static float e;
private CameraState() {
}
public static void L(float f, float g, float h, float i) {
j = fx;
h = g;
L = hx;
M = ix;
H = true;
}
public static void L() {
H = false;
}
public static void L(Entity entity) {
if (m && entity != null) {
entity.rotationYaw = l;
entity.rotationPitch = I;
entity.prevRotationYaw = f;
entity.prevRotationPitch = d;
if (entity instanceof EntityLivingBase entityLivingBase) {
((EntityLivingBase)entity).rotationYawHead = i;
entityLivingBase.prevRotationYawHead = e;
}
m = false;
}
}
public static boolean L(Entity entity) {
if (H && entity != null && !m) {
l = entity.rotationYaw;
I = entity.rotationPitch;
f = entity.prevRotationYaw;
d = entity.prevRotationPitch;
entity.rotationYaw = j;
entity.rotationPitch = h;
entity.prevRotationYaw = L;
entity.prevRotationPitch = M;
if (entity instanceof EntityLivingBase entityLivingBase) {
EntityLivingBase entityLivingBase1 = (EntityLivingBase)entity;
i = ((EntityLivingBase)entity).rotationYawHead;
e = entityLivingBase.prevRotationYawHead;
entityLivingBase1.rotationYawHead = j;
entityLivingBase.prevRotationYawHead = L;
}
m = true;
return true;
} else {
return false;
}
}
public static boolean L() {
return H;
}
}