Upload files to "src/openonyx/render/group_m"
This commit is contained in:
1 parent
0bba811b0f
commit
68c4785159
4 files changed
+238
No files matched your search
@@ -0,0 +1,6 @@
|
||||
package openonyx.render.group_m;
|
||||
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
public record TrailPoint(Vec3 position, long time) {
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package openonyx.render.group_m;
|
||||
|
||||
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.Vec3;
|
||||
import openonyx.core.MinecraftAccess;
|
||||
import openonyx.core.OnyxClient;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class TrailsRenderer implements MinecraftAccess {
|
||||
private boolean i;
|
||||
private static final float f = 0.8F;
|
||||
private static final float H = 0.004F;
|
||||
private static final float e = 2.5F;
|
||||
|
||||
private static int L(int i) {
|
||||
return ix >> 24 & 0xFF;
|
||||
}
|
||||
|
||||
public void d() {
|
||||
this.i = true;
|
||||
}
|
||||
|
||||
private static void L(boolean bl) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.disableFog();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.disableCull();
|
||||
GlStateManager.depthMask(false);
|
||||
GlStateManager.shadeModel(7425);
|
||||
if (bl) {
|
||||
GlStateManager.disableDepth();
|
||||
}
|
||||
|
||||
GL11.glEnable(2848);
|
||||
GL11.glHint(3154, 4354);
|
||||
}
|
||||
|
||||
public void L(float f, List<TrailPoint> list, float g, TrailsStyle trailsStyle) {
|
||||
TrailsRenderer trailsRenderer1 = this;
|
||||
if (trailsRenderer1.i) {
|
||||
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 l = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
switch (trailsStyle.mode()) {
|
||||
case WALL:
|
||||
while (false) {
|
||||
}
|
||||
|
||||
if (list.size() >= 2) {
|
||||
trailsRenderer1.L(list, g, trailsStyle, vec3, l);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case POINTS:
|
||||
if (list.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
trailsRenderer1.L(list, trailsStyle, vec3, l);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
trailsRenderer1.i = false;
|
||||
OnyxClient.LOGGER.warn("Trails renderer has been disabled after a render failure", throwable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TrailsRenderer() {
|
||||
int ix = 4 ^ 5;
|
||||
super();
|
||||
this.i = (boolean)ix;
|
||||
}
|
||||
|
||||
private static int d(int i, int j) {
|
||||
return Math.clamp(j, 0, 255) << 24 | ix & 16777215;
|
||||
}
|
||||
|
||||
private void L(Tessellator tessellator, WorldRenderer worldRenderer, List<TrailPoint> list, float f, TrailsStyle trailsStyle, Vec3 vec3, long l) {
|
||||
worldRenderer.begin(3, DefaultVertexFormats.POSITION_COLOR);
|
||||
Iterator iterator;
|
||||
Iterator iterator1 = iterator = list.iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
TrailPoint trailPoint = (TrailPoint)iterator.next();
|
||||
iterator1 = iterator;
|
||||
L(worldRenderer, trailPoint.position(), fx, vec3, d(trailsStyle, L(trailPoint, trailsStyle, l)));
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
private static int L(int i, int j) {
|
||||
return ix >> j & 0xFF;
|
||||
}
|
||||
|
||||
private static void L(WorldRenderer worldRenderer, Vec3 vec3, float f, Vec3 vec31, int i) {
|
||||
worldRenderer.pos(vec3.xCoord - vec31.xCoord, vec3.yCoord + fx - vec31.yCoord, vec3.zCoord - vec31.zCoord)
|
||||
.color(L(ix, 16), L(ix, 8), L(ix, 0), L(ix))
|
||||
.endVertex();
|
||||
}
|
||||
|
||||
private static int d(TrailsStyle trailsStyle, float f) {
|
||||
return d(trailsStyle.color(), (int)(255.0F * Math.min(1.0F, trailsStyle.opacity() * 2.5F) * fx));
|
||||
}
|
||||
|
||||
private static float L(TrailPoint trailPoint, TrailsStyle trailsStyle, long l) {
|
||||
return 1.0F - Math.clamp((float)(l - trailPoint.time()) / (float)trailsStyle.lifetime(), 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
private static int L(TrailsStyle trailsStyle, float f) {
|
||||
return d(trailsStyle.color(), (int)(255.0F * trailsStyle.opacity() * fx));
|
||||
}
|
||||
|
||||
private void L(List<TrailPoint> list, float f, TrailsStyle trailsStyle, Vec3 vec3, long l) {
|
||||
TrailsRenderer trailsRenderer1 = this;
|
||||
Tessellator tessellator;
|
||||
WorldRenderer worldRenderer = (tessellator = Tessellator.getInstance()).getWorldRenderer();
|
||||
int m = 0;
|
||||
L(trailsStyle.throughWalls());
|
||||
worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
|
||||
for (int ix = 0; m < list.size() - 1; m = ix) {
|
||||
TrailPoint trailPoint = (TrailPoint)list.get(ix);
|
||||
TrailPoint trailPoint1;
|
||||
TrailPoint trailPoint2 = trailPoint1 = (TrailPoint)list.get(ix + 1);
|
||||
int j = L(trailsStyle, L(trailPoint, trailsStyle, l));
|
||||
int k = L(trailsStyle, L(trailPoint2, trailsStyle, l));
|
||||
L(worldRenderer, trailPoint.position(), 0.0F, vec3, j);
|
||||
L(worldRenderer, trailPoint.position(), fx, vec3, j);
|
||||
L(worldRenderer, trailPoint1.position(), fx, vec3, k);
|
||||
Vec3 vec31 = trailPoint1.position();
|
||||
ix++;
|
||||
L(worldRenderer, vec31, 0.0F, vec3, k);
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
GL11.glLineWidth(trailsStyle.lineWidth());
|
||||
trailsRenderer1.L(tessellator, worldRenderer, list, 0.004F, trailsStyle, vec3, l);
|
||||
trailsRenderer1.L(tessellator, worldRenderer, list, fx - 0.004F, trailsStyle, vec3, l);
|
||||
L();
|
||||
}
|
||||
|
||||
private void L(List<TrailPoint> list, TrailsStyle trailsStyle, Vec3 vec3, long l) {
|
||||
Tessellator tessellator;
|
||||
WorldRenderer worldRenderer = (tessellator = Tessellator.getInstance()).getWorldRenderer();
|
||||
L(trailsStyle.throughWalls());
|
||||
GL11.glEnable(2832);
|
||||
GL11.glHint(3153, 4354);
|
||||
GL11.glPointSize(trailsStyle.pointSize());
|
||||
worldRenderer.begin(0, DefaultVertexFormats.POSITION_COLOR);
|
||||
Iterator iterator;
|
||||
Iterator iterator1 = iterator = list.iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
TrailPoint trailPoint = (TrailPoint)iterator.next();
|
||||
iterator1 = iterator;
|
||||
L(worldRenderer, trailPoint.position(), 0.8F, vec3, d(trailsStyle, L(trailPoint, trailsStyle, l)));
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
GL11.glPointSize(1.0F);
|
||||
GL11.glDisable(2832);
|
||||
L();
|
||||
}
|
||||
|
||||
private static void L() {
|
||||
GL11.glLineWidth(1.0F);
|
||||
GL11.glDisable(2848);
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package openonyx.render.group_m;
|
||||
|
||||
import openonyx.features.render.Mode;
|
||||
|
||||
// $VF: synthetic class
|
||||
class TrailsRendererPart {
|
||||
static {
|
||||
int[] i = new int[Mode.values().length];
|
||||
boolean bl = true;
|
||||
e = i;
|
||||
|
||||
try {
|
||||
e[Mode.WALL.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError noSuchFieldError1) {
|
||||
}
|
||||
|
||||
try {
|
||||
e[Mode.POINTS.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError noSuchFieldError) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package openonyx.render.group_m;
|
||||
|
||||
import openonyx.features.render.Mode;
|
||||
|
||||
public record TrailsStyle(Mode mode, int color, float opacity, long lifetime, float lineWidth, float pointSize, boolean throughWalls) {
|
||||
}
|
||||
Reference in new issue
Block a user