CubeParticle hotfix

- Switched to additive cube particle mode
- Fixed cube particles not rendering properly with other entities in frame
This commit is contained in:
simibubi 2020-07-19 00:50:03 +02:00
parent 257dc11f55
commit a009540190

View File

@ -1,7 +1,11 @@
package com.simibubi.create.content.contraptions.particle; package com.simibubi.create.content.contraptions.particle;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.IVertexBuilder; import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.particle.IParticleFactory; import net.minecraft.client.particle.IParticleFactory;
import net.minecraft.client.particle.IParticleRenderType; import net.minecraft.client.particle.IParticleRenderType;
import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.Particle;
@ -13,7 +17,6 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
public class CubeParticle extends Particle { public class CubeParticle extends Particle {
@ -38,20 +41,13 @@ public class CubeParticle extends Particle {
public static final Vec3d[] CUBE_NORMALS = { public static final Vec3d[] CUBE_NORMALS = {
// modified normals for the sides // modified normals for the sides
new Vec3d(0, 1, 0), new Vec3d(0, 1, 0), new Vec3d(0, -1, 0), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1),
new Vec3d(0, -1, 0),
new Vec3d(0, 0, 1),
new Vec3d(0, 0, 1),
new Vec3d(0, 0, 1),
new Vec3d(0, 0, 1), new Vec3d(0, 0, 1),
/*
/*new Vec3d(0, 1, 0), * new Vec3d(0, 1, 0), new Vec3d(0, -1, 0), new Vec3d(0, 0, 1), new Vec3d(0, 0,
new Vec3d(0, -1, 0), * -1), new Vec3d(-1, 0, 0), new Vec3d(1, 0, 0)
new Vec3d(0, 0, 1), */
new Vec3d(0, 0, -1),
new Vec3d(-1, 0, 0),
new Vec3d(1, 0, 0)*/
}; };
private static final IParticleRenderType renderType = new IParticleRenderType() { private static final IParticleRenderType renderType = new IParticleRenderType() {
@ -60,15 +56,16 @@ public class CubeParticle extends Particle {
RenderSystem.disableTexture(); RenderSystem.disableTexture();
// transparent, additive blending // transparent, additive blending
//RenderSystem.depthMask(false); RenderSystem.depthMask(false);
//RenderSystem.enableBlend(); RenderSystem.enableBlend();
//RenderSystem.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE); RenderSystem.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
//RenderSystem.enableLighting(); RenderSystem.enableLighting();
RenderSystem.enableColorMaterial();
// opaque // opaque
RenderSystem.depthMask(true); // RenderSystem.depthMask(true);
RenderSystem.disableBlend(); // RenderSystem.disableBlend();
RenderSystem.enableLighting(); // RenderSystem.enableLighting();
builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
} }
@ -76,6 +73,8 @@ public class CubeParticle extends Particle {
@Override @Override
public void finishRender(Tessellator tessellator) { public void finishRender(Tessellator tessellator) {
tessellator.draw(); tessellator.draw();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA,
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.enableTexture(); RenderSystem.enableTexture();
} }
}; };
@ -121,7 +120,12 @@ public class CubeParticle extends Particle {
.add(lerpedX, lerpedY, lerpedZ); .add(lerpedX, lerpedY, lerpedZ);
Vec3d normal = CUBE_NORMALS[i]; Vec3d normal = CUBE_NORMALS[i];
builder.vertex(vec.x, vec.y, vec.z).color(particleRed, particleGreen, particleBlue, particleAlpha).texture(0,0).light(light).normal((float)normal.x,(float) normal.y,(float) normal.z).endVertex(); builder.vertex(vec.x, vec.y, vec.z)
.color(particleRed, particleGreen, particleBlue, particleAlpha)
.texture(0, 0)
.light(light)
.normal((float) normal.x, (float) normal.y, (float) normal.z)
.endVertex();
} }
} }
} }
@ -136,7 +140,8 @@ public class CubeParticle extends Particle {
public Factory() {} public Factory() {}
@Override @Override
public Particle makeParticle(CubeParticleData data, World world, double x, double y, double z, double motionX, double motionY, double motionZ) { public Particle makeParticle(CubeParticleData data, World world, double x, double y, double z, double motionX,
double motionY, double motionZ) {
CubeParticle particle = new CubeParticle(world, x, y, z, motionX, motionY, motionZ); CubeParticle particle = new CubeParticle(world, x, y, z, motionX, motionY, motionZ);
particle.setColor(data.r, data.g, data.b); particle.setColor(data.r, data.g, data.b);
particle.setScale(data.scale); particle.setScale(data.scale);