Upload files to "src/openonyx/render/group_a"

This commit is contained in:
winterflyt committed 2026-11-30 06:08:31 +02:00
1 parent f23e29a1aa
commit 76e375fd62
4 files changed
+452

No files matched your search

@@ -0,0 +1,116 @@
package openonyx.render.group_a;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import openonyx.core.MinecraftAccess;
import openonyx.features.render.FeatureSupport_327Mode;
import openonyx.features.render.ThemeMode;
import openonyx.render.BoxRenderer;
import openonyx.theme.internal.ColorUtils;
public final class BlockOverlayBox implements MinecraftAccess {
private static final double e = 0.0015;
public static AxisAlignedBB L(BlockPos blockPos) {
return AxisAlignedBB.fromBounds(blockPos.getX(), blockPos.getY(), blockPos.getZ(), blockPos.getX() + 1, blockPos.getY() + 1, blockPos.getZ() + 1);
}
private static AxisAlignedBB L(AxisAlignedBB axisAlignedBB, float f, BlockOverlayStyle blockOverlayStyle) {
if (blockOverlayStyle.progressMode() == FeatureSupport_327Mode.GROW) {
return L(axisAlignedBB, f);
}
double d = (axisAlignedBB.maxY - axisAlignedBB.minY) * f;
return blockOverlayStyle.progressUpward()
? L(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ, axisAlignedBB.maxX, axisAlignedBB.minY + d, axisAlignedBB.maxZ)
: L(axisAlignedBB.minX, axisAlignedBB.maxY - d, axisAlignedBB.minZ, axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ);
}
private static AxisAlignedBB L(double d, double e, double f, double g, double h, double i) {
double j = Math.min(0.0015, (g - d) / 2.0);
double k = Math.min(0.0015, (h - ex) / 2.0);
double l = Math.min(0.0015, (i - f) / 2.0);
return AxisAlignedBB.fromBounds(d + j, ex + k, f + l, g - j, h - k, i - l);
}
public void L() {
BlockOverlayShader.L();
}
public void L(float f, BlockPos blockPos, AxisAlignedBB axisAlignedBB, float g, float h, BlockOverlayStyle blockOverlayStyle) {
if (!(g <= 0.0F)) {
boolean bl;
AxisAlignedBB axisAlignedBB1;
boolean bl3;
label57: {
bl = blockOverlayStyle.progress() && h > 0.001F;
axisAlignedBB1 = bl ? L(axisAlignedBB, h, blockOverlayStyle) : axisAlignedBB;
boolean bl2 = bl && blockOverlayStyle.progressMode() == FeatureSupport_327Mode.FILL;
if (blockOverlayStyle.theme() == ThemeMode.GLINT && blockPos != null) {
AxisAlignedBB axisAlignedBB4;
boolean bl4;
if (bl2) {
axisAlignedBB4 = axisAlignedBB;
bl4 = bl2;
} else {
axisAlignedBB4 = axisAlignedBB1;
bl4 = bl2;
}
AxisAlignedBB axisAlignedBB3;
float i;
if (bl4) {
axisAlignedBB3 = axisAlignedBB1;
i = g;
} else {
axisAlignedBB3 = null;
i = g;
}
if (BlockOverlayShader.L(f, blockPos, axisAlignedBB4, axisAlignedBB3, i, blockOverlayStyle)) {
bl3 = true;
break label57;
}
}
bl3 = false;
}
boolean bl1 = bl3;
if (BoxRenderer.L(f, blockOverlayStyle.throughWalls())) {
label49: {
if (bl) {
if (!bl1) {
axisAlignedBB2 = axisAlignedBB;
BoxRenderer.L(axisAlignedBB1, 0, 0.0F, ColorUtils.withAlpha(blockOverlayStyle.color(), g * blockOverlayStyle.progressOpacity()));
break label49;
}
} else if (blockOverlayStyle.theme() == ThemeMode.FILL && !bl1) {
BoxRenderer.L(axisAlignedBB, 0, 0.0F, ColorUtils.withAlpha(blockOverlayStyle.color(), g * blockOverlayStyle.fillOpacity()));
}
axisAlignedBB2 = axisAlignedBB;
}
BoxRenderer.L(
axisAlignedBB2, ColorUtils.withAlpha(blockOverlayStyle.color(), g * blockOverlayStyle.outlineOpacity()), blockOverlayStyle.lineWidth(), 0
);
BoxRenderer.L();
}
}
}
private static AxisAlignedBB L(AxisAlignedBB axisAlignedBB, float f) {
double d = (axisAlignedBB.minX + axisAlignedBB.maxX) / 2.0;
double ex = (axisAlignedBB.minY + axisAlignedBB.maxY) / 2.0;
double g = (axisAlignedBB.minZ + axisAlignedBB.maxZ) / 2.0;
return AxisAlignedBB.fromBounds(
d + (axisAlignedBB.minX - d) * f,
ex + (axisAlignedBB.minY - ex) * f,
g + (axisAlignedBB.minZ - g) * f,
d + (axisAlignedBB.maxX - d) * f,
ex + (axisAlignedBB.maxY - ex) * f,
g + (axisAlignedBB.maxZ - g) * f
);
}
}
@@ -0,0 +1,271 @@
package openonyx.render.group_a;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
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.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.src.Config;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import openonyx.core.MinecraftAccess;
import openonyx.core.OnyxClient;
import openonyx.render.group_p.ShaderProgram;
import org.lwjgl.opengl.GL11;
public final class BlockOverlayShader implements MinecraftAccess {
private static final long I = System.nanoTime();
private static final int d = 256;
private static ShaderProgram shaderProgram;
private static boolean f;
private static boolean H = true;
private static final double e = 0.001;
private static void L(
float f,
BlockPos blockPos,
IBlockState iBlockState,
Block block,
Entity entity,
AxisAlignedBB axisAlignedBB,
AxisAlignedBB axisAlignedBB1,
float g,
BlockOverlayStyle blockOverlayStyle
) {
double dx = entity.prevPosX + (entity.posX - entity.prevPosX) * fx;
double ex = entity.prevPosY + (entity.posY - entity.prevPosY) * fx;
double h = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * fx;
AxisAlignedBB axisAlignedBB2 = BlockOverlayBox.L(blockPos);
double i = L(axisAlignedBB.maxX - axisAlignedBB.minX, axisAlignedBB2.maxX - axisAlignedBB2.minX);
double j = L(axisAlignedBB.maxY - axisAlignedBB.minY, axisAlignedBB2.maxY - axisAlignedBB2.minY);
double k = L(axisAlignedBB.maxZ - axisAlignedBB.minZ, axisAlignedBB2.maxZ - axisAlignedBB2.minZ);
double l = (axisAlignedBB2.minX + axisAlignedBB2.maxX) / 2.0 - dx;
double m = (axisAlignedBB2.minY + axisAlignedBB2.maxY) / 2.0 - ex;
double n = (axisAlignedBB2.minZ + axisAlignedBB2.maxZ) / 2.0 - h;
double o = (axisAlignedBB.minX + axisAlignedBB.maxX - axisAlignedBB2.minX - axisAlignedBB2.maxX) / 2.0;
double p = (axisAlignedBB.minY + axisAlignedBB.maxY - axisAlignedBB2.minY - axisAlignedBB2.maxY) / 2.0;
double q = (axisAlignedBB.minZ + axisAlignedBB.maxZ - axisAlignedBB2.minZ - axisAlignedBB2.maxZ) / 2.0;
L(blockOverlayStyle.throughWalls());
GlStateManager.translate(o, p, q);
GlStateManager.translate(l, m, n);
GlStateManager.scale(i, j, k);
GlStateManager.translate(-l, -m, -n);
shaderProgram.use();
shaderProgram.setUniform1i("Sampler0", 0);
shaderProgram.setUniform4f("uColorPrimary", d(blockOverlayStyle.color()), D(blockOverlayStyle.color()), L(blockOverlayStyle.color()), g);
shaderProgram.setUniform4f(
"uColorSecondary",
d(blockOverlayStyle.secondColor()),
D(blockOverlayStyle.secondColor()),
L(blockOverlayStyle.secondColor()),
blockOverlayStyle.glintAmount()
);
shaderProgram.setUniform4f("uMotion", L(), blockOverlayStyle.glintSpeed(), blockOverlayStyle.glintScale(), blockOverlayStyle.glintGlow());
shaderProgram.setUniform4f("uOrigin", (float)(axisAlignedBB2.minX - dx), (float)(axisAlignedBB2.minY - ex), (float)(axisAlignedBB2.minZ - h), 0.0F);
if (axisAlignedBB1 == null) {
shaderProgram.setUniform4f("uCrop", 0.0F, 0.0F, 0.0F, 0.0F);
} else {
shaderProgram.setUniform4f("uCrop", (float)L(axisAlignedBB1.minY - ex, m, j, p), (float)L(axisAlignedBB1.maxY - ex, m, j, p), 1.0F, 0.0F);
}
shaderProgram.setUniform4f("uWorld", Math.floorMod(blockPos.getX(), 256), Math.floorMod(blockPos.getY(), 256), Math.floorMod(blockPos.getZ(), 256), 0.0F);
shaderProgram.setUniform1f("uFogEnabled", GL11.glIsEnabled(2912) ? 1.0F : 0.0F);
Tessellator tessellator;
WorldRenderer worldRenderer = (tessellator = Tessellator.getInstance()).getWorldRenderer();
worldRenderer.begin(7, DefaultVertexFormats.BLOCK);
worldRenderer.setTranslation(-dx, -ex, -h);
L(worldRenderer, axisAlignedBB2);
if (axisAlignedBB1 != null) {
boolean bl;
dx = (bl = blockOverlayStyle.progressUpward()) ? axisAlignedBB1.maxY : axisAlignedBB1.minY;
L(worldRenderer, axisAlignedBB2, L(dx - ex, m, j, p) + ex, bl);
}
tessellator.draw();
worldRenderer.setTranslation(0.0, 0.0, 0.0);
ShaderProgram.unbind();
d();
}
private static float D(int i) {
return (i >> 8 & 0xFF) / 255.0F;
}
private static void L(WorldRenderer worldRenderer, double d, double e, double f) {
worldRenderer.pos(dx, ex, fx).color(255, 255, 255, 255).tex(0.0, 0.0).lightmap(240, 240).endVertex();
}
private BlockOverlayShader() {
}
private static float d(int i) {
return (i >> 16 & 0xFF) / 255.0F;
}
private static void L(WorldRenderer worldRenderer, AxisAlignedBB axisAlignedBB) {
EnumFacing[] enumFacings;
int j = (enumFacings = EnumFacing.values()).length;
int i;
for (int k = i = 0; k < j; k = ++i) {
EnumFacing enumFacing = enumFacings[i];
switch (enumFacing) {
case DOWN:
while (false) {
}
L(worldRenderer, axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ);
L(worldRenderer, axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ);
L(worldRenderer, axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ);
L(worldRenderer, axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ);
break;
case UP:
L(worldRenderer, axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ);
L(worldRenderer, axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ);
L(worldRenderer, axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ);
L(worldRenderer, axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ);
break;
case NORTH:
L(worldRenderer, axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ);
L(worldRenderer, axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ);
L(worldRenderer, axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ);
L(worldRenderer, axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ);
break;
case SOUTH:
L(worldRenderer, axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ);
L(worldRenderer, axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ);
L(worldRenderer, axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ);
L(worldRenderer, axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ);
break;
case WEST:
L(worldRenderer, axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ);
L(worldRenderer, axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ);
L(worldRenderer, axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ);
L(worldRenderer, axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ);
break;
case EAST:
L(worldRenderer, axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ);
L(worldRenderer, axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ);
L(worldRenderer, axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ);
L(worldRenderer, axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ);
}
}
}
public static boolean L(float f, BlockPos blockPos, AxisAlignedBB axisAlignedBB, AxisAlignedBB axisAlignedBB1, float g, BlockOverlayStyle blockOverlayStyle) {
if (!H || mc.theWorld == null) {
return false;
}
if (!OpenGlHelper.shadersSupported) {
return false;
}
if (Config.isShaders()) {
return false;
}
Entity entity;
if ((entity = mc.getRenderViewEntity()) == null) {
return false;
}
IBlockState iBlockState;
Block block;
if ((block = (iBlockState = mc.theWorld.getBlockState(blockPos)).getBlock()).getRenderType() != 3) {
return false;
}
if (!f) {
f = true;
shaderProgram = ShaderProgram.load("onyx_block_glint");
}
if (shaderProgram != null && shaderProgram.isLoaded()) {
try {
L(fx, blockPos, iBlockState, block, entity, axisAlignedBB, axisAlignedBB1, g, blockOverlayStyle);
return true;
} catch (Throwable throwable) {
H = false;
OnyxClient.LOGGER.warn("Block overlay glint has been disabled after a render failure", throwable);
return false;
}
} else {
H = false;
return false;
}
}
private static void d() {
GlStateManager.doPolygonOffset(0.0F, 0.0F);
GlStateManager.disablePolygonOffset();
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(boolean bl) {
GlStateManager.pushMatrix();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
GlStateManager.enableTexture2D();
GlStateManager.disableLighting();
GlStateManager.disableFog();
GlStateManager.enableBlend();
GlStateManager.blendFunc(770, 771);
GlStateManager.disableAlpha();
GlStateManager.enableCull();
GlStateManager.depthMask(false);
GlStateManager.doPolygonOffset(-1.0F, -10.0F);
GlStateManager.enablePolygonOffset();
if (bl) {
GlStateManager.disableDepth();
}
}
private static float L() {
return (float)((System.nanoTime() - I) % 3600000000000L) / 1.0E9F;
}
static void L() {
H = true;
}
private static double L(double d, double e) {
return dx / Math.max(ex, 1.0E-4);
}
private static float L(int i) {
return (i & 0xFF) / 255.0F;
}
private static void L(WorldRenderer worldRenderer, AxisAlignedBB axisAlignedBB, double d, boolean bl) {
double ex = bl ? dx - 0.001 : dx + 0.001;
L(worldRenderer, axisAlignedBB.minX, ex, axisAlignedBB.maxZ);
L(worldRenderer, axisAlignedBB.maxX, ex, axisAlignedBB.maxZ);
L(worldRenderer, axisAlignedBB.maxX, ex, axisAlignedBB.minZ);
L(worldRenderer, axisAlignedBB.minX, ex, axisAlignedBB.minZ);
L(worldRenderer, axisAlignedBB.minX, ex, axisAlignedBB.minZ);
L(worldRenderer, axisAlignedBB.maxX, ex, axisAlignedBB.minZ);
L(worldRenderer, axisAlignedBB.maxX, ex, axisAlignedBB.maxZ);
L(worldRenderer, axisAlignedBB.minX, ex, axisAlignedBB.maxZ);
}
private static double L(double d, double e, double f, double g) {
return (dx - ex - g) / Math.max(fx, 1.0E-4) + ex;
}
}
@@ -0,0 +1,42 @@
package openonyx.render.group_a;
import net.minecraft.util.EnumFacing;
// $VF: synthetic class
class BlockOverlayShaderPart {
static {
int[] i = new int[EnumFacing.values().length];
boolean bl = true;
e = i;
try {
e[EnumFacing.DOWN.ordinal()] = 1;
} catch (NoSuchFieldError noSuchFieldError5) {
}
try {
e[EnumFacing.UP.ordinal()] = 2;
} catch (NoSuchFieldError noSuchFieldError4) {
}
try {
e[EnumFacing.NORTH.ordinal()] = 3;
} catch (NoSuchFieldError noSuchFieldError3) {
}
try {
e[EnumFacing.SOUTH.ordinal()] = 4;
} catch (NoSuchFieldError noSuchFieldError2) {
}
try {
e[EnumFacing.WEST.ordinal()] = 5;
} catch (NoSuchFieldError noSuchFieldError1) {
}
try {
e[EnumFacing.EAST.ordinal()] = 6;
} catch (NoSuchFieldError noSuchFieldError) {
}
}
}
@@ -0,0 +1,23 @@
package openonyx.render.group_a;
import openonyx.features.render.FeatureSupport_327Mode;
import openonyx.features.render.ThemeMode;
public record BlockOverlayStyle(
ThemeMode theme,
int color,
int secondColor,
float lineWidth,
float outlineOpacity,
float fillOpacity,
float glintAmount,
float glintSpeed,
float glintScale,
float glintGlow,
boolean progress,
FeatureSupport_327Mode progressMode,
boolean progressUpward,
float progressOpacity,
boolean throughWalls
) {
}