Move particles even closer to vanilla systems. i.e. render them at the same time as regular particles, not in the RenderWorldLastEvent. Bump forge.

This commit is contained in:
Vincent Lee committed 2019-10-11 13:36:00 -05:00
1 parent 8d759ff126
commit 7fe136d400
10 files changed
+161 -219

No files matched your search

@@ -13,13 +13,12 @@ package vazkii.botania.client.fx;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.IParticleRenderType;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.SpriteTexturedParticle;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.BufferBuilder;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
@@ -35,17 +34,10 @@ public class FXWisp extends Particle {
private static final ResourceLocation vanillaParticles = new ResourceLocation("textures/particle/particles.png");
public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_WISP_LARGE);
private static final Queue<FXWisp> queuedRenders = new ArrayDeque<>();
private static final Queue<FXWisp> queuedDepthIgnoringRenders = new ArrayDeque<>();
protected float particleScale = (this.rand.nextFloat() * 0.5F + 0.5F) * 2.0F;
// Queue values
private float f;
private float f1;
private float f2;
private float f3;
private float f4;
private float f5;
private final boolean depthTest;
private final float moteParticleScale;
private final int moteHalfLife;
public FXWisp(World world, double d, double d1, double d2, double xSpeed, double ySpeed, double zSpeed,
float size, float red, float green, float blue, boolean depthTest, float maxAgeMul) {
@@ -71,38 +63,8 @@ public class FXWisp extends Particle {
prevPosZ = posZ;
}
public static void dispatchQueuedRenders(Tessellator tessellator) {
ParticleRenderDispatcher.wispFxCount = 0;
ParticleRenderDispatcher.depthIgnoringWispFxCount = 0;
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 0.75F);
Minecraft.getInstance().textureManager.bindTexture(ConfigHandler.CLIENT.matrixMode.get() ? vanillaParticles : particles);
if(!queuedRenders.isEmpty()) {
tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
for(FXWisp wisp : queuedRenders)
wisp.renderQueued(tessellator, true);
tessellator.draw();
}
if(!queuedDepthIgnoringRenders.isEmpty()) {
GlStateManager.disableDepthTest();
tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
for(FXWisp wisp : queuedDepthIgnoringRenders)
wisp.renderQueued(tessellator, false);
tessellator.draw();
GlStateManager.enableDepthTest();
}
queuedRenders.clear();
queuedDepthIgnoringRenders.clear();
}
private void renderQueued(Tessellator tessellator, boolean depthEnabled) {
if(depthEnabled)
ParticleRenderDispatcher.wispFxCount++;
else ParticleRenderDispatcher.depthIgnoringWispFxCount++;
@Override
public void renderParticle(BufferBuilder buffer, ActiveRenderInfo entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
float agescale = (float)age / (float) moteHalfLife;
if (agescale > 1F)
agescale = 2 - agescale;
@@ -110,36 +72,22 @@ public class FXWisp extends Particle {
particleScale = moteParticleScale * agescale;
float f10 = 0.5F * particleScale;
float f11 = (float)(prevPosX + (posX - prevPosX) * f - interpPosX);
float f12 = (float)(prevPosY + (posY - prevPosY) * f - interpPosY);
float f13 = (float)(prevPosZ + (posZ - prevPosZ) * f - interpPosZ);
float f11 = (float)(prevPosX + (posX - prevPosX) * partialTicks - interpPosX);
float f12 = (float)(prevPosY + (posY - prevPosY) * partialTicks - interpPosY);
float f13 = (float)(prevPosZ + (posZ - prevPosZ) * partialTicks - interpPosZ);
int combined = 15 << 20 | 15 << 4;
int k3 = combined >> 16 & 0xFFFF;
int l3 = combined & 0xFFFF;
tessellator.getBuffer().pos(f11 - f1 * f10 - f4 * f10, f12 - f2 * f10, f13 - f3 * f10 - f5 * f10).tex(0, 1).lightmap(k3, l3).color(particleRed, particleGreen, particleBlue, 0.5F).endVertex();
tessellator.getBuffer().pos(f11 - f1 * f10 + f4 * f10, f12 + f2 * f10, f13 - f3 * f10 + f5 * f10).tex(1, 1).lightmap(k3, l3).color(particleRed, particleGreen, particleBlue, 0.5F).endVertex();
tessellator.getBuffer().pos(f11 + f1 * f10 + f4 * f10, f12 + f2 * f10, f13 + f3 * f10 + f5 * f10).tex(1, 0).lightmap(k3, l3).color(particleRed, particleGreen, particleBlue, 0.5F).endVertex();
tessellator.getBuffer().pos(f11 + f1 * f10 - f4 * f10, f12 - f2 * f10, f13 + f3 * f10 - f5 * f10).tex(0, 0).lightmap(k3, l3).color(particleRed, particleGreen, particleBlue, 0.5F).endVertex();
}
@Override
public void renderParticle(BufferBuilder buffer, ActiveRenderInfo entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
this.f = partialTicks;
this.f1 = rotationX;
this.f2 = rotationZ;
this.f3 = rotationYZ;
this.f4 = rotationXY;
this.f5 = rotationXZ;
if(depthTest)
queuedRenders.add(this);
else queuedDepthIgnoringRenders.add(this);
buffer.pos(f11 - rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 - rotationYZ * f10 - rotationXZ * f10).tex(0, 1).lightmap(k3, l3).color(particleRed, particleGreen, particleBlue, 0.5F).endVertex();
buffer.pos(f11 - rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 - rotationYZ * f10 + rotationXZ * f10).tex(1, 1).lightmap(k3, l3).color(particleRed, particleGreen, particleBlue, 0.5F).endVertex();
buffer.pos(f11 + rotationX * f10 + rotationXY * f10, f12 + rotationZ * f10, f13 + rotationYZ * f10 + rotationXZ * f10).tex(1, 0).lightmap(k3, l3).color(particleRed, particleGreen, particleBlue, 0.5F).endVertex();
buffer.pos(f11 + rotationX * f10 - rotationXY * f10, f12 - rotationZ * f10, f13 + rotationYZ * f10 - rotationXZ * f10).tex(0, 0).lightmap(k3, l3).color(particleRed, particleGreen, particleBlue, 0.5F).endVertex();
}
@Nonnull
@Override
public IParticleRenderType getRenderType() {
return IParticleRenderType.CUSTOM;
return depthTest ? NORMAL_RENDER : DIW_RENDER;
}
// [VanillaCopy] of super, without drag when onGround is true
@@ -171,7 +119,61 @@ public class FXWisp extends Particle {
motionZ = mz;
}
private boolean depthTest;
private final float moteParticleScale;
private final int moteHalfLife;
private static void beginRenderCommon(BufferBuilder bufferBuilder, TextureManager textureManager) {
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
GlStateManager.depthMask(false);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GlStateManager.alphaFunc(GL11.GL_GREATER, 0.003921569F);
GlStateManager.disableLighting();
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 0.75F);
textureManager.bindTexture(ConfigHandler.CLIENT.matrixMode.get() ? vanillaParticles : particles);
bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
}
private static void endRenderCommon() {
GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
GlStateManager.disableBlend();
GlStateManager.depthMask(true);
GL11.glPopAttrib();
}
private static final IParticleRenderType NORMAL_RENDER = new IParticleRenderType() {
@Override
public void beginRender(BufferBuilder bufferBuilder, TextureManager textureManager) {
beginRenderCommon(bufferBuilder, textureManager);
}
@Override
public void finishRender(Tessellator tessellator) {
tessellator.draw();
endRenderCommon();
}
@Override
public String toString() {
return "botania:wisp";
}
};
private static final IParticleRenderType DIW_RENDER = new IParticleRenderType() {
@Override
public void beginRender(BufferBuilder bufferBuilder, TextureManager textureManager) {
beginRenderCommon(bufferBuilder, textureManager);
GlStateManager.disableDepthTest();
}
@Override
public void finishRender(Tessellator tessellator) {
tessellator.draw();
GlStateManager.enableDepthTest();
endRenderCommon();
}
@Override
public String toString() {
return "botania:depth_ignoring_wisp";
}
};
}